Sample function code:
unsigned char *digestBIO(unsigned char *data, int datal) { BIO *bc=NULL,*b=NULL; const EVP_MD *md = EVP_sha1(); static unsigned char bDigest[EVP_MAX_MD_SIZE] = {0};
bc = BIO_new (BIO_f_md()); BIO_set_md (bc, md);
b= BIO_new(BIO_s_null()); //b= BIO_new(BIO_s_mem());
b=BIO_push(bc,b);
len=BIO_write (b, data, datal); len=BIO_gets(b,(char*)tmp, 1024);
BIO_free_all(b);
return tmp; } |