I'm trying to duplicate PHP's crypt()
function in JavaScript with regards to generating a SHA512 hash, such as this:
$hash = crypt( $text, '$6$' . $salt );
This generates something like this:
$6$salt$hashedtext
I'm trying with CryptoJS, like this:
var hash = CryptoJS.SHA512( text );
And this does generate the SHA512 hash for me, like this:
hashedtext
But I don't see any way to supply a salt. I've never used CryptoJS before, so I'm totally novice on this.. but I've done some googling and haven't been able to locate an answer to this. Hopefully it's simple and just evading me.
How can I generate a string that matches the above-formatted string returned by the crypt()
example?