simple bcrypt library for C

user441521 picture user441521 · Dec 10, 2012 · Viewed 9.9k times · Source

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)

Answer

Alex I picture Alex I · Dec 18, 2012

Your C options for bcrypt seem to be:

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,