Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Looking for Perl crypt() function in node.js.

perl -e 'print crypt("", "12345")'

return: 12UFlHxel6uMM
Looking the same in node.js

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
163 views
Welcome To Ask or Share your Answers For Others

1 Answer

There is a powerful and well supported node package for password encryption - bcrypt.

What you want is:

var bcrypt = require('bcrypt');
var hash = bcrypt.hashSync('', '12345');

See bcrypt API Docs for more info.


Updated. You can also use Node crypto module. In this case you may use crypto.pbkdf2 method. I newer used it myself, so I can't guarantee its stability, usability and security.

I also can't guarantee than either bcrypt or crypto uses the same algorithm for password hashing as Perl crypt method. So the result may be different from Perl crypt even if salt is the same.

Though Node crypto is a build-in module, I strongly recommend you to use bcrypt if possible, because its more secure.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...