Created
July 24, 2012 13:03
-
-
Save Zenithar/3169823 to your computer and use it in GitHub Desktop.
Hashing algorithm conform to Owasp.
This file contains 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
crypto = require("crypto") | |
# | |
# Hashing algorithm conform to Owasp. | |
# https://www.owasp.org/index.php/Hashing_Java | |
# | |
exports.secureHash = (algorithm, key, message, iterations) -> | |
hash = crypto.createHash(algorithm) | |
hmac = crypto.createHmac(algorithm, key) | |
buf = hash.update(key).digest() + message | |
i = 0 | |
while i < iterations - 1 | |
buf = hmac.update(buf).digest() | |
hmac = crypto.createHmac(algorithm, key) | |
i++ | |
hmac = crypto.createHmac(algorithm, key) | |
hmac.update(buf).digest "base64" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment