如何使用 C# 取消散列哈希? [英] How can I unhash a hash using C#?

查看:15
本文介绍了如何使用 C# 取消散列哈希?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以反转我正在使用的这个方便的哈希码吗?

Can someone reverse this handy hash code I'm using?

using System.Security.Cryptography;

public static string EncodePasswordToBase64(string password)
{  byte[] bytes   = Encoding.Unicode.GetBytes(password);
   byte[] inArray = HashAlgorithm.Create("SHA1").ComputeHash(bytes);
   return Convert.ToBase64String(inArray);
}

我最终做的一切都失败了:(.

Everything I end up doing fails horribly :(.

推荐答案

不,您不能反转散列.典型的过程是将其他输入与您拥有的哈希值进行比较,以检查它们是否相同.

No, you can't reverse a hash. The typical process is to compare other input to the hash you have, to check if they are the same.

喜欢(伪):

initial  = Hash(password);
possible = Hash("test");

if( initial == possible ){
    // we infer that password = "test"
}

但请注意,不应再使用 SHA1、SHA0 和 MD5;(由于不同程度的破碎).你应该使用 SHA-2

But note that SHA1, SHA0, and MD5 should no longer be used; (due to various degrees of breaking in each). You should use SHA-2

这篇关于如何使用 C# 取消散列哈希?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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