Problem with digest Hmac sha256 method and another problem while using openssl hmac
kerdemdemir
kerdemdemir at gmail.com
Fri Dec 8 21:05:27 UTC 2017
Hi,
I need to have the same result while using :
openssl dgst -sha256 -hmac "somestring"
But the server rejecting my generated hmac with the code below .
auto hmac = HMAC!SHA256("somestring".representation);
hmac.put(url.representation);
auto generatedHmac = hmac.finish();
string generatedHmacStr =
std.digest.digest.toHexString(generatedHmac);
Saying generatedHmac is not correct.
Than I wanted to give a try with deimos-openssl like:
ubyte[32] hmac_sha256( string key, string data) {
HMAC_CTX *ctx = new HMAC_CTX;
HMAC_CTX_init(ctx);
auto digest = HMAC(EVP_sha256(),
cast(void *) key,
cast(int) key.length,
cast(ubyte*) data,
cast(int) data.length,
null,null);
ubyte[32] array = digest[0..32];
return array;
}
But I am getting a linking error :
undefined reference to
`_D6deimos7openssl3evp13env_md_ctx_st6__initZ'
My dependencies in dub.json file is like:
"dependencies": {
"openssl": "~>1.1.6+1.0.1g",
"vibe-d": "~>0.8.1",
}
I really want to solve linking error first. I tried installing
openssl it didn't help. Any suggestions?
Regards
Erdem
More information about the Digitalmars-d-learn
mailing list