library/src/utility/BP-StringUtilities.cc
// Generates a SHA1 has provided given input.  Returned string must be bpfreed.
Generates a SHA1 has provided given input.  Returned string must be bpfreed.
Generates a SHA1 has provided given input . Returned string must be bpfreed .
char * BP_GenSHA1(char *in, size_t in_size)
{
	if(!in || !in_size)
		return NULL;
	char *sha1_ascii = (char *) bpcalloc(41, 1);
	unsigned char obuf[20];
	SHA1((unsigned char *) in, in_size, (unsigned char *) &obuf);
	size_t i = 0;
	for(; i < 20; i++)
	{
		snprintf((char *) &sha1_ascii[bpstrlen(sha1_ascii)], 4, "%.02x", obuf[i]);
	}
	return sha1_ascii;
}
char * BP_GenSHA1 ( char * in , size_t in_size ) { if ( ! in || ! in_size ) return NULL ; char * sha1_ascii = ( char * ) bpcalloc ( 41 , 1 ) ; unsigned char obuf [ 20 ] ; SHA1 ( ( unsigned char * ) in , in_size , ( unsigned char * ) & obuf ) ; size_t i = 0 ; for ( ; i < 20 ; i ++ ) { snprintf ( ( char * ) & sha1_ascii [ bpstrlen ( sha1_ascii ) ] , 4 , " " , obuf [ i ] ) ; } return sha1_ascii ; }
Generates a SHA1 has provided given input.
Generates a SHA1 has provided given input .
// now create ascii buffer // 20 byte outbuffer // create hash // create ascii hash from binary // return the ascii