hash

It takes a string, a secret and a hashing algorithm to hash the original a string. It's a helper for the hashSHA256 and hashSHA512 functions. You can build your own hashing function based on this function by passing the hashing algorightm in the third parameter. Bear in mind that only SSL available algorithms would work.
You can get a list of hash types your OpenSSL supports by typing openssl list-cipher-commands into the command line for older versions, or openssl list-cipher-algorithms for newer versions of OpenSSL.
Parameter ListReturnsRejection Errors
  • stringToHash: string
  • secret: string (optional)
  • hashingAlgorith: string
  • tuple: Array (optional)
Promise<string || Array>
Related FunctionsFunction Signature
function hash(stringToHash[, secret tuple]): Promise<string || Array>
1 2 3 4 5 6 7 8 import {hash} from 'puddy-m/lib/helpers' const originalString = 'puddy-m', const secret = "Don't tell anybody."; hash(originalString, secret, 'md5').then((hashedVersion) => console.log(hashedVersion) ); // 21bfaa418d087aee55f903db934d11d4
1 2 3 4 5 6 7 import { hash } from "puddy-m/lib/helpers";const originalString = "puddy-m"; const secret = "Don't tell anybody."; hash(originalString, secret, "md5", []) .then((tuple) => hash(originalString, "", "sha1", tuple)) .then(([hash1, hash2]) => console.log("1st:" + hash1 + " 2nd:" + hash2)); // 1st:21bfaa418d087aee55f903db934d11d4 2nd:9571909174302b9412a75576ee806843a09f3eaf