Created
September 25, 2024 19:54
-
-
Save joscha/b2f96866e4fb29c9dfadec7472ef0eb6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
var crypto_1 = require("crypto"); | |
var util_1 = require("util"); | |
/** | |
* Compute a string's hash. | |
* | |
* @param str The string to hash. | |
* @param algorithm The algorithm used. | |
*/ | |
function getHash(str, algorithm) { | |
if (algorithm === void 0) { algorithm = 'md5'; } | |
var hash = (0, crypto_1.createHash)(algorithm); | |
hash.end(str); | |
var buf = hash.read(); | |
return new Uint8Array(buf.buffer, buf.byteOffset, buf.length); | |
} | |
module.exports = { | |
getHash: getHash, | |
debuglog: util_1.debuglog, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment