Ivan Grokhotkov / hmac_md5

Dependents:   RFrec_full RFtrans_full

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers hmac_md5.cpp Source File

hmac_md5.cpp

00001 #include "hmac_md5.h"
00002 #include "hmac.h"
00003 #include "coding.h"
00004 
00005 void HMAC_MD5(const char * szKey, const char * szText, char * szOutput)
00006 {
00007     Hmac hmac;
00008     char hmacOutput[MD5_DIGEST_SIZE + 1];
00009 
00010     HmacSetKey(&hmac, MD5, (const byte *) szKey, strlen(szKey));
00011     HmacUpdate(&hmac, (const byte *) szText, strlen(szText));
00012     
00013     HmacFinal(&hmac, (byte *) hmacOutput);
00014     
00015     int encodedLength = 25;
00016     Base64_Encode((const byte *) hmacOutput, MD5_DIGEST_SIZE, (byte *) szOutput, (word32*) &encodedLength);
00017     szOutput[encodedLength] = 0;
00018 
00019 }