Created
May 6, 2019 03:01
-
-
Save iaoedsz2008/f240d471afa9bfd175fc0f331d337071 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void hmac_sha256 (const unsigned char* input, int inputlength, unsigned char* output, unsigned int* outputlength) | |
{ | |
const EVP_MD* engine = EVP_sha256 (); | |
#if OPENSSL_VERSION_NUMBER < 0x10100000L | |
HMAC_CTX ctx; | |
HMAC_CTX_init (&ctx); | |
HMAC_Init_ex (&ctx, API_SECRET_KEY, strlen (API_SECRET_KEY), engine, NULL); | |
HMAC_Update (&ctx, (const unsigned char*)input, inputlength); | |
HMAC_Final (&ctx, output, outputlength); | |
#else | |
HMAC_CTX* ctx = HMAC_CTX_new (); | |
HMAC_Init_ex (ctx, API_SECRET_KEY, strlen (API_SECRET_KEY), engine, NULL); | |
HMAC_Update (ctx, (const unsigned char*)input, inputlength); | |
HMAC_Final (ctx, output, outputlength); | |
HMAC_CTX_free (ctx); | |
#endif | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment