[Interest] hmac sha256

Jérôme Godbout godboutj at amotus.ca
Mon Oct 15 23:16:00 CEST 2018


Hi,
I'm trying to find the C++ equivalent of this python:
*import hashlib*
*import hmac*
*hmac.new(bytearray(m_api_secret, 'utf-8'), bytearray(payload, 'utf-8'),
hashlib.sha256).hexdigest()*

Or my Javascript equivalent (both give the same results):
crypto.createHmac("sha256", m_api_secret).update(payload).digest("hex");

I have try the following:

   - QMessageAuthenticationCode::hash(payload,
   QByteArray::fromHex(m_api_secret), QCryptographicHash::Sha256).toHex();
   - QMessageAuthenticationCode::hash(payload,
   QByteArray::fromHex(m_api_secret), QCryptographicHash::Sha3_256).toHex();
   - QMessageAuthenticationCode::hash(payload, m_api_secret,
   QCryptographicHash::Sha256).toHex();
   - QMessageAuthenticationCode::hash(payload, m_api_secret,
   QCryptographicHash::Sha3_256).toHex();
   - QMessageAuthenticationCode::hash(QByteArray::fromHex(payload),
   QByteArray::fromHex(m_api_secret), QCryptographicHash::Sha256).toHex();
   - QMessageAuthenticationCode::hash(QByteArray::fromHex(payload),
   QByteArray::fromHex(m_api_secret), QCryptographicHash::Sha3_256).toHex();

But I never get the same results as the Python or Javascript one. Maybe I'm
using the wrong class here. Anybody have a good pointer on how to do this?
Any good hmac sha256 class to perform this?

-- 



RAPPROCHEZ LA DISTANCE


*Jérôme Godbout*Senior Software Developer

*p:* +1 (418) 800-1073 ext.:109

*m:* +1 (581) 777-0050

amotus.ca <http://www.amotus-solutions.com/>
statum-iot.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20181015/01da848c/attachment.html>


More information about the Interest mailing list