如何解密SHA256? [英] How can decrypte SHA256 ?

查看:221
本文介绍了如何解密SHA256?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



使用以下流程来加密某些文本。我怎样才能解密结果。

public static string GetSHA256( string text)
{
UnicodeEncoding ue = new UnicodeEncoding ();
byte [] hashValue;
// byte [] message = ue.GetBytes(NYRR+ text +RRYN);
byte [] message = ue.GetBytes(text.Length * 2 + text + text.Length * 2 );

SHA256Managed hashString = new SHA256Managed();
string hex = ;

hashValue = hashString.ComputeHash(message);
foreach byte x in hashValue)
{
hex + = String .Format( {0:x2},x);
}
return hex;
}





我的尝试:



  public   static   string  GetSHA256( string  text)
{
UnicodeEncoding ue = new UnicodeEncoding();
byte [] hashValue;
// byte [] message = ue.GetBytes(NYRR+ text +RRYN);
byte [] message = ue.GetBytes(text.Length * 2 + text + text.Length * 2 );

SHA256Managed hashString = new SHA256Managed();
string hex = ;

hashValue = hashString.ComputeHash(message);
foreach byte x in hashValue)
{
hex + = String .Format( {0:x2},x);
}
return hex;
}

解决方案

SHA 等哈希函数是由定义单向意味着散列过程会丢失结果中的信息,并且不能用于加密。


< blockquote class =quote>

Quote:

如何解密SHA256

你不能因为SHA256不加密。

就像用数字命理学。在数字命理学中,你给出一个名称的值,通过对每个字母给出的值求和,你不能反转过程。


SHA256是一种散列方法,而不是加密方法。您无法解密哈希值,因为它是基于被哈希的字符串值的数学确定值。


Hi ,

I am using follwoing process to Encrypt the certain text .How can i decrypt the result.

public static string GetSHA256(string text)
  {
      UnicodeEncoding ue = new UnicodeEncoding();
      byte[] hashValue;
      //byte[] message = ue.GetBytes("NYRR" + text + "RRYN");
      byte[] message = ue.GetBytes(text.Length * 2 + text + text.Length * 2);

      SHA256Managed hashString = new SHA256Managed();
      string hex = "";

      hashValue = hashString.ComputeHash(message);
      foreach (byte x in hashValue)
      {
          hex += String.Format("{0:x2}", x);
      }
      return hex;
  }



What I have tried:

public static string GetSHA256(string text)
  {
      UnicodeEncoding ue = new UnicodeEncoding();
      byte[] hashValue;
      //byte[] message = ue.GetBytes("NYRR" + text + "RRYN");
      byte[] message = ue.GetBytes(text.Length * 2 + text + text.Length * 2);

      SHA256Managed hashString = new SHA256Managed();
      string hex = "";

      hashValue = hashString.ComputeHash(message);
      foreach (byte x in hashValue)
      {
          hex += String.Format("{0:x2}", x);
      }
      return hex;
  }

解决方案

Hash functions like SHA etc. are by definition one-way meaning that the process of hashing will loose information in the result, and cannot be used for encryption.


Quote:

How can decrypte SHA256

You can't because SHA256 is not encryption.
It is like with numerology. In numerology you give give a value to a name by summing the values given to each letters, you can't reverse the process.


SHA256 is a hashing method, not an encryption method. You can't decrypt a hash value because it's a mathematically determined value based on the value of the string being hashed.


这篇关于如何解密SHA256?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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