Maverickgugu
Maverickgugu

Reputation: 777

What are some widely used cryptography / hash libraries in C?

I've been working on cryptography implementations in C. I am required to use hash a message using any one of the popular hash functions like SHA,MD5, etc.

In Java, there is a security library which takes care of these things.
But how do I do the same in C?

for example: char *str = "this is a message"; char *hash = SHA(str);

Something of this sort. It would be of great help if some one can point me to some library which has already implemented these functions which i can call for my program.

Thanks!

Upvotes: 6

Views: 3738

Answers (2)

Henno Brandsma
Henno Brandsma

Reputation: 2166

OpenSSL is indeed widely available. For your example you could use

unsigned char digest[SHA_DIGEST_LENGTH]; 
char *str = "this is a string";
SHA1(str, strlen(str), digest);

Upvotes: 4

Thomas Pornin
Thomas Pornin

Reputation: 74382

sphlib is an opensource library which provides optimized (but portable) implementations in C of many hash functions.

OpenSSL is a more generic cryptographic library, which is widely deployed and provides implementations of hash functions, too (less hash functions than sphlib, but it also includes other cryptographic primitives).

Upvotes: 10

Related Questions