Vous ne pouvez pas sélectionner plus de 25 sujets
Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
15 lignes
355 B
15 lignes
355 B
'use strict';
|
|
|
|
var sha2 = module.exports;
|
|
|
|
var encoder = new TextEncoder();
|
|
sha2.sum = function (alg, str) {
|
|
var data = str;
|
|
if ('string' === typeof data) {
|
|
data = encoder.encode(str);
|
|
}
|
|
var sha = 'SHA-' + String(alg).replace(/^sha-?/i, '');
|
|
return window.crypto.subtle.digest(sha, data).then(function (buf) {
|
|
return new Uint8Array(buf);
|
|
});
|
|
};
|
|
|