L
L
lightalex2018-11-21 01:09:47
C++ / C#
lightalex, 2018-11-21 01:09:47

What is the ComputeHash equivalent of the HMACSHA1 class from C# in C++?

Good day
There is a code in C #:

HMACSHA1 hmacGenerator = new HMACSHA1();
hmacGenerator.Key = sharedSecretArray;
byte[] hashedData = hmacGenerator.ComputeHash(timeArray);

timeArray is byte[8]
sharedSecretArray is byte[]
How to get hash similarly in C++?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman, 2018-11-21
@lightalex

cryptopp

S
SerJook, 2018-11-21
@SerJook

You can use openssl

#include <openssl/hmac.h>
// ...
std::string key = ... ;
unsigned char timeArray[8] = ... ;
unsigned char* hashedData = HMAC(EVP_sha1(), &key[0], key.length(), timeArray, sizeof(timeArray), NULL, NULL);  
// hashedData указывает на 20 байт хэша

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question