问题
I have tried for days to get bcrypt installed on my windows machine with no luck. One of the dependencies (Windows 7 SDK) does not want to be installed even though I have tried numerous suggestions from around the net it just refuses to cooperate.
I need a good alternative to bcrypt which does not have any dependencies.
回答1:
Check out https://npmjs.org/package/bcryptjs, it's fully compatible with bcrypt just without the dependencies.
Or https://npmjs.org/package/simplecrypt if you don't want the crypto boilerplate and just need to encrypt and decrypt strings.
回答2:
If someone faces similar issue, you can try bcyrptjs which is optimized bcrypt written in JavaScript with zero dependencies and is also compatible to the C++ bcrypt.
回答3:
You should really use the built-in crypto module for your encryption needs. It's basically a binding to OpenSSL, a fast, stable, secure, and well-vetted crypto library. Trying to implement your own crypto (or use someone else's unvalidated attempt at implementing crypto) is a recipe for disaster.
If you're looking to encrypt data, all you have to do is call crypto.createCipher, which returns a readable/writable Stream. Write data into the stream and it will emit data events with the encrypted data.
For example:
var stream = crypto.createCipher('aes192', 'mysecretpassword');
stream.on('data', function(enc) {
// enc is a `Buffer` with a chunk of encrypted data
});
stream.write('some secret data');
stream.end();
来源:https://stackoverflow.com/questions/19822643/what-is-an-alternative-for-bcrypt-to-use-with-node