Feature/ws cli (#15)
* New command line tool for transfering files / still very beta. * add readme * use cli11 for argument parsing * json -> msgpack * stop using base64 and use binary which can be stored in message pack
This commit is contained in:
committed by
GitHub
parent
709a5ec89a
commit
2d696b6806
27
ws/ixcrypto/IXHMac.cpp
Normal file
27
ws/ixcrypto/IXHMac.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* IXHMac.h
|
||||
* Author: Benjamin Sergeant
|
||||
* Copyright (c) 2018 Machine Zone. All rights reserved.
|
||||
*/
|
||||
#include "IXHMac.h"
|
||||
#include "IXBase64.h"
|
||||
|
||||
#include <openssl/hmac.h>
|
||||
|
||||
namespace ix
|
||||
{
|
||||
std::string hmac(const std::string& data, const std::string& key)
|
||||
{
|
||||
constexpr size_t hashSize = 16;
|
||||
unsigned char hash[hashSize];
|
||||
|
||||
HMAC(EVP_md5(),
|
||||
key.c_str(), (int) key.size(),
|
||||
(unsigned char *) data.c_str(), (int) data.size(),
|
||||
(unsigned char *) hash, nullptr);
|
||||
|
||||
std::string hashString(reinterpret_cast<char*>(hash), hashSize);
|
||||
|
||||
return base64_encode(hashString, (uint32_t) hashString.size());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user