1
0
Fork 0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2025-07-04 20:46:39 +02:00

Added TextMetrics protection

Fixes #448
This commit is contained in:
kkapsner 2020-03-14 12:54:23 +01:00
parent 692b4616e2
commit ec128796e3
18 changed files with 328 additions and 3 deletions

View file

@ -1,6 +1,10 @@
const testAPI = function(){
"use strict";
const digest = crypto.subtle? crypto.subtle.digest.bind(crypto.subtle, "SHA-256"): function(buffer){
return new Uint32Array(buffer.buffer);
};
function bufferToString(hash){
const chunks = [];
(new Uint32Array(hash)).forEach(function(num){
@ -18,7 +22,7 @@ const testAPI = function(){
const buffer = ((typeof input) === "string")?
new TextEncoder("utf-8").encode(input):
input;
const hash = await crypto.subtle.digest("SHA-256", buffer);
const hash = await digest(buffer);
return bufferToString(hash);
}
};