{"ScriptPreparationCode":"async function sign256(path, secret) {\r\n const encoder = new TextEncoder();\r\n const data = encoder.encode(path);\r\n const key = await crypto.subtle.importKey(\r\n \u0027raw\u0027,\r\n encoder.encode(secret),\r\n { name: \u0027HMAC\u0027, hash: \u0027SHA-256\u0027 },\r\n false,\r\n [\u0027sign\u0027]\r\n );\r\n const signature = await crypto.subtle.sign(\u0027HMAC\u0027, key, data);\r\n const hashArray = Array.from(new Uint8Array(signature));\r\n const base64Hash = btoa(String.fromCharCode(...hashArray))\r\n\r\n return base64Hash \u002B \u0027/\u0027 \u002B path;\r\n}\r\n\r\nasync function sign512(path, secret) {\r\n const encoder = new TextEncoder();\r\n const data = encoder.encode(path);\r\n const key = await crypto.subtle.importKey(\r\n \u0027raw\u0027,\r\n encoder.encode(secret),\r\n { name: \u0027HMAC\u0027, hash: \u0027SHA-512\u0027 },\r\n false,\r\n [\u0027sign\u0027]\r\n );\r\n const signature = await crypto.subtle.sign(\u0027HMAC\u0027, key, data);\r\n const hashArray = Array.from(new Uint8Array(signature));\r\n const base64Hash = btoa(String.fromCharCode(...hashArray))\r\n\r\n return base64Hash \u002B \u0027/\u0027 \u002B path;\r\n}\r\n","TestCases":[{"Name":"sha512","Code":"sign512(\u0027500x500/top/raw.githubusercontent.com/cshum/imagor/master/testdata/gopher.png\u0027, \u0027mysecret\u0027).then(result =\u003E result)","IsDeferred":false},{"Name":"sha256","Code":"sign256(\u0027500x500/top/raw.githubusercontent.com/cshum/imagor/master/testdata/gopher.png\u0027, \u0027mysecret\u0027).then(result =\u003E result)","IsDeferred":false}]}