#include #include #include static char misc_tohex(unsigned n) { if (n >= 10){ return n-10+'A'; }else{ return n+'0'; } } /* Compute the SHA digest of a string and store it in hex form in res */ void misc_sha ( const char *s, SSTRING &res) { unsigned char tmp[SHA_DIGEST_LENGTH]; SHA1 ((const unsigned char*)s,strlen(s),tmp); char tmphex[SHA_DIGEST_LENGTH*2+1]; for (int i=0; i>4); tmphex[i*2+1] = misc_tohex(byte&0xf); } tmphex[2*SHA_DIGEST_LENGTH] = '\0'; res.setfrom (tmphex); }