如何使用 C# 取消散列哈希?

编程入门 行业动态 更新时间:2024-10-28 01:24:52
本文介绍了如何使用 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屋!

更多推荐

[db:关键词]

本文发布于:2023-03-31 01:18:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/793576.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   列哈希

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!