Possible Duplicate:
sha1 function in cpp (C++)Hi,
I was just looking for a function that calculates the sha1 hash of string and returns the result.
Possible Duplicate:
sha1 function in cpp (C++)Hi,
I was just looking for a function that calculates the sha1 hash of string and returns the result.
Not built-in. Try openssl's crypto library.
(https://www.openssl.org/source/)
(https://github.com/openssl/openssl/blob/master/include/openssl/sha.h)
(https://www.openssl.org/docs/man1.1.0/crypto/SHA1.html)
#include <openssl/sha.h>
int main()
{  
  const unsigned char str[] = "Original String";
  unsigned char hash[SHA_DIGEST_LENGTH]; // == 20
  SHA1(str, sizeof(str) - 1, hash);
  // do some stuff with the hash
  return 0;
}
Link with -lssl, which will imply -lcrypto. If you are linking statically you might need to link both.
Here's an example: http://www.codeproject.com/KB/recipes/csha1.aspx#csha1is
Also, this question was already addressed on this thread. They have a link for some further help. Check it out.
Check out this post on Ubuntu Forums.  They suggest looking in libcrypt.
Also there's an implementation here but I'm not sure what the license is.