在C#中使用带有密钥的HMACSHA256对字符串进行解密 [英] Decryption of string using HMACSHA256 with key in C#

查看:2432
本文介绍了在C#中使用带有密钥的HMACSHA256对字符串进行解密的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个加密的字符串(使用HMACSHA256用密钥编码)。现在我如何使用密钥和HMACSHA256算法对其进行解密?

I have an encrypted string (encoded with a key using HMACSHA256). Now how can I decrypt it back using the key and HMACSHA256 algorithm?

推荐答案

这个问题毫无意义。 这不是加密。并且您的字符串无法解密,因为没有加密。我不知道您称之为密钥,但您没有密钥。可能你只有基于哈希的消息认证码,只有HMAC值本身,它不包含你认为你加密的字符串。你没有。你从来没有提到你有加密数据。



请参阅:

http://en.wikipedia.org/wiki/Hash-based_message_authentication_code [ ^ ],

https://msdn.microsoft.com/en-us/library/system.security.cryptography.hmacsha256%28v=vs.110%29.aspx [ ^ ]。



了解某些内容可以基于哈希以及加密哈希,请参阅:

http://en.wikipedia.org/wiki / Cryptographic_hash_func [ ^ ],

另见 http://en.wikipedia.org/wiki/SHA-2 [ ^ ]。



-SA
The question make no sense at all. This is not encryption. And your string cannot be decrypted, because nothing was encrypted. I don't know what do you call a "key", but you don't have a key. Probably you have only the hash-based message authentication code, only HMAC value itself, which does not contains the string you thought you "encrypted". You did not. You never mentioned you had "encrypted data".

Please see:
http://en.wikipedia.org/wiki/Hash-based_message_authentication_code[^],
https://msdn.microsoft.com/en-us/library/system.security.cryptography.hmacsha256%28v=vs.110%29.aspx[^].

To understand how something can be hash-based and what cryptographic hash does, please see:
http://en.wikipedia.org/wiki/Cryptographic_hash_function[^],
see also http://en.wikipedia.org/wiki/SHA-2[^].

—SA


这篇关于在C#中使用带有密钥的HMACSHA256对字符串进行解密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆