A easier way to digest. Only notes that BIO_f_xx() algorithm is a filter BIO, can’t be used alone, you have to combine a BIO_s_xx() to go with it, which stands for a source BIO.
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;