Answer the question
In order to leave comments, you need to log in
How to get a string of 20 characters in SHA1 (c++ and openssl)?
Good afternoon.
PHP has a SHA1 function , its second argument allows you to "shorten" the final hash.
echo SHA1('Hello World', true).'</br>';
echo SHA1('Hello World');
...
unsigned char obuf[20];
SHA1((const unsigned char *)st, strlen(st), obuf);
char mdString[SHA_DIGEST_LENGTH*2+1];
for(int i = 0; i < SHA_DIGEST_LENGTH; i++)
sprintf(&mdString[i*2], "%02x", (unsigned int)obuf[i]);
...
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question