Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <openssl/evp.h>
- #include <openssl/hmac.h>
- int main()
- {
- char msg[] = "A simple string";
- char key[] = "key";
- HMAC_CTX hmac;
- HMAC_Init_ex(&hmac, key, strlen(key), EVP_sha256(), NULL);
- HMAC_Update(&hmac, (const unsigned char*)msg, strlen(msg));
- unsigned int md_len = HMAC_size(&hmac);
- unsigned char md[md_len];
- HMAC_Final(&hmac, md, &md_len);
- // dump resulting digest
- for (size_t i=0; i<md_len; ++i)
- printf("%02X", md[i]);
- printf("\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement