2
0
mirror of https://github.com/therootcompany/acme.js synced 2025-02-23 16:18:06 +00:00
acme.js/lib/browser/sha2.js

14 lines
298 B
JavaScript
Raw Normal View History

2019-10-04 17:35:59 -06:00
'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);
};