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

18 lines
369 B
JavaScript
Raw Normal View History

2019-10-04 17:35:59 -06:00
/* global Promise */
'use strict';
var sha2 = module.exports;
var crypto = require('crypto');
sha2.sum = function(alg, str) {
return Promise.resolve().then(function() {
var sha = 'sha' + String(alg).replace(/^sha-?/i, '');
// utf8 is the default for strings
var buf = Buffer.from(str);
return crypto
.createHash(sha)
.update(buf)
.digest();
});
};