Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const {
- Hash
- } = require('crypto')
- /**
- * @param {String} str
- * @param {String} algorith
- * @returns Hashed String
- */
- module.exports = (str, algorithm) => {
- let hashed = ""
- let x = new Hash(algorithm)
- x.on('readable', () => {
- let z = x.read()
- if (z) hashed += z.toString("hex")
- })
- x.write(str)
- x.end()
- return hashed
- }
Add Comment
Please, Sign In to add comment