I'm looking for a simple to use cross-platform bcrypt library for C. I've searched around a couple places but nothing seems to compares to the ease of use of:
http://bcrypt.codeplex.com/SourceControl/changeset/view/1eef0262901c#BCrypt.Net.Test%2fTestBCrypt.cs
Why are all the C implementations of this a nightmare compared to this .NET lib? Basically 2 functions is what I'm looking for.
1) Generate salt (return a string)
2) Hash string using a given salt & pw (return a string)
The basic idea for using bcrypt.genSalt was generate Salt for my password which need to encrypted.The Syntax for using bcrypt.genSalt is as follows. bcrypt.genSalt(rounds, cb) rounds - [OPTIONAL] - the cost of processing the data. ( default - 10) cb - [REQUIRED] - a callback to be fired once the salt has been generated ...
Bcrypt does not have a database it stores the salt... The salt is added to the hash in base64 format....
A BCrypt hash includes salt and as a result this algorithm returns different hashes for the same input.
Asynchronous Hashing The bcrypt. hash() function takes in the plain password and a salt as input, and returns a hashed string.
Your C options for bcrypt seem to be:
In OpenBSD: https://github.com/openbsd/src/blob/master/lib/libc/crypt/bcrypt.c
In OpenWall: http://openwall.com/crypt/
The C implementations seem to be pretty straightforward to use. The OpenBSD version looks like this:
char *bcrypt(const char *key, const char *salt);
char *bcrypt_gensalt(u_int8_t log_rounds);
P.S. Consider scrypt for new code, if you are not restricted to using bcrypt only due to backward compatibility,
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