Please help with php -> javascript(node.js) conversion
$key = crypt($key, $salt);
I'm rewriting php script with node.js, and I got stuck with hash signature generation in php, which is made using crypt() function with salt matching "CRYPT_EXT_DES" pattern
CRYPT_EXT_DES - Extended DES-based hash. The "salt" is a 9-character string consisting of an underscore followed by 4 bytes of iteration count and 4 bytes of salt. These are encoded as printable characters, 6 bits per character, least significant character first. The values 0 to 63 are encoded as "./0-9A-Za-z". Using invalid characters in the salt will cause crypt() to fail.
I'm not really experienced with encryption, and studying node.js docs on crypto module didnt help. Please help how to implement this on node.js!
It looks like the crypt(3) library should work.
E.g.:
const crypt = require( 'crypt3/sync' ),
key = "password",
hash = crypt( key, crypt.createSalt( 'sha512' ) );
And then to test stored hash...
const crypt = require( 'crypt3/sync' ),
key = "password",
hash = /* stored hash */;
if ( crypt( key, hash ) !== hash ) {
// access denied
return false;
}
(six year late, I know)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With