library/src/utility/BP-StringUtilities.cc
// Attempts to generate a sha256 hash.
Attempts to generate a sha256 hash.
Attempts to generate a sha256 hash .
char * BP_GenSHA256(char *in, size_t in_size)
{
	if(!in)
		return NULL;
	if(!in_size)
		return NULL;
	BP_SHA256_CTX ctx;
	unsigned char hash[32] = {0};
	sha256_init(&ctx);
	sha256_update(&ctx, (unsigned char *) in, in_size);
	sha256_final(&ctx,hash);
	char * txt_sha256 = BP_BufferToHexString((char *) &hash, 32);
	return txt_sha256;
}
char * BP_GenSHA256 ( char * in , size_t in_size ) { if ( ! in ) return NULL ; if ( ! in_size ) return NULL ; BP_SHA256_CTX ctx ; unsigned char hash [ 32 ] = { 0 } ; sha256_init ( & ctx ) ; sha256_update ( & ctx , ( unsigned char * ) in , in_size ) ; sha256_final ( & ctx , hash ) ; char * txt_sha256 = BP_BufferToHexString ( ( char * ) & hash , 32 ) ; return txt_sha256 ; }
Attempts to generate a sha256 hash.
Attempts to generate a sha256 hash .
// ensure we have a buffer and a size // context to use // space for the hash // init the context // calculate the hash // generate the final hash // create the hash output before returning // return the duplicated hash