Lightweight, Zero-Dependency RSA and EC/ECDSA crypto for Node.js and Browsers
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

15 lines
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);
});
};