mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-14 22:41:21 -04:00
Initial community commit
This commit is contained in:
parent
537bcbc862
commit
20d28e80a5
16810 changed files with 4640254 additions and 2 deletions
Src/auth
31
Src/auth/OAuthKey.cpp
Normal file
31
Src/auth/OAuthKey.cpp
Normal file
|
@ -0,0 +1,31 @@
|
|||
#include "OAuthKey.h"
|
||||
#include "b64.h"
|
||||
|
||||
OAuthKey::OAuthKey(const void *key, size_t key_len)
|
||||
{
|
||||
HMAC_SHA256_Init(&ctx);
|
||||
HMAC_SHA256_UpdateKey(&ctx, (unsigned char *)key, (int)key_len);
|
||||
HMAC_SHA256_EndKey(&ctx);
|
||||
HMAC_SHA256_StartMessage(&ctx);
|
||||
}
|
||||
|
||||
OAuthKey::~OAuthKey()
|
||||
{
|
||||
HMAC_SHA256_Done(&ctx);
|
||||
}
|
||||
|
||||
void OAuthKey::FeedMessage(const void *data, size_t data_len)
|
||||
{
|
||||
HMAC_SHA256_UpdateMessage(&ctx, (unsigned char *)data, (unsigned int)data_len);
|
||||
}
|
||||
|
||||
void OAuthKey::EndMessage()
|
||||
{
|
||||
HMAC_SHA256_EndMessage(buf, &ctx);
|
||||
}
|
||||
|
||||
void OAuthKey::GetBase64(char *output, size_t cch)
|
||||
{
|
||||
size_t len = b64::b64_encode(buf, HMAC_SHA256_DIGEST_LENGTH, output, cch);
|
||||
output[len] = '\0';
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue