我发现了基于哈希的消息身份验证代码(HMAC)以及如何与SHA-256哈希一起使用。
我遵循该链接。
因此,我尝试了一下,并了解如何生成HMAC,请参阅下面的片段:
mySecret = b"....."
h = HMAC.new(mySecret, digestmod = SHA256)
h.update(b"hello")
print (h.hexdigest()) # 1bef439a8c4fe14770480ebe819cb2e7d5cd68ca4ccf4b3c1f248fc2a525b0a9
这部分的一切都可以。
然后,我搜索如何将其逆转并获得 mySecret
回去。我必须承认我没有想法。
有可能做到吗?
谢谢。
I discovered the Hash-based Message Authentication Code (HMAC) and how to use it with a SHA-256 hash for example.
I follow that link https://pycryptodome.readthedocs.io/en/latest/src/hash/hmac.html.
So I gave it a try and understood how to generate a HMAC, see the snippet below :
mySecret = b"....."
h = HMAC.new(mySecret, digestmod = SHA256)
h.update(b"hello")
print (h.hexdigest()) # 1bef439a8c4fe14770480ebe819cb2e7d5cd68ca4ccf4b3c1f248fc2a525b0a9
Everything is ok on this part.
Then I searched how I could do to reverse it and get mySecret
back. And I must admit I have no ideas to make it.
It it possible to do it ?
Thanks.
发布评论