Python SHA1 DECODE函数 [英] Python SHA1 DECODE function

查看:93
本文介绍了Python SHA1 DECODE函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找不到如何解码在sha1中编码的字符串。令我感到惊讶的是,我无法在python文档或google中找到进行sha1解码的简单功能。我放弃。我需要帮助。

解决方案

SHA1是一种哈希算法。散列是一种单向方式,这意味着您无法从输出中恢复任何非平凡散列函数的输入。单向哈希函数的一个简单示例是将一个数字的所有数字加在一起。 1234 会散列为 1 + 2 + 3 + 4 = 10 ,但 4321也是如此 1900 5050 和许多其他数字。仅给出哈希值 10 ,您就无法确定输入是 1234 还是 5050 因为信息丢失。



以下是一个图形示例:



< a href = https://en.wikipedia.org/w/index.php?title=文件:Hash_table_4_1_1_0_0_1_0_LL.svg rel = nofollow noreferrer>



如您所见,都是 John Smith code>和 Sandra Dee 映射到 02 。这意味着仅给出 02 ,您就无法恢复被散列的 名称。



散列很有用,因为它将任意数据量映射到固定大小的输出,并且与上述示例不同,极其很难找到两个散列到的输入相同的输出。 仅对一对具有相同哈希值的SHA-1输入花费了6,500 CPU年。 / p>

因此,如果 hash(A)== hash(B),那么您可以确信 A == B 。如果您复制一个巨大的文件,并且原始副本和副本的哈希值都相同,则可以确定该文件是完整的。


I cant find how to decode string encoded in sha1. I'm suprised that i can't find simple function in python docs or google doing sha1 decoding. I give up. I need help..

解决方案

SHA1 is a hashing algorithm. Hashing is one-way, which means that you can't recover the input from the output for any non-trivial hash function. A simple example of a one-way hash function would be adding together all the digits of a number. 1234 would hash to 1 + 2 + 3 + 4 = 10, but so would 4321, 1900, 5050, and many other numbers. Given just the hash value of 10, you can't tell whether the input was 1234 or 5050 because information was lost.

Here's a graphical example:

As you can see, both John Smith and Sandra Dee are mapped to 02. This means that you can't recover which name was hashed given only 02.

Hashing is useful because it maps any amount of data to a fixed-size output and, unlike in the above examples, it is extremely difficult to find two inputs that hash to the same output. It took over 6,500 CPU-years to find just a single pair inputs to SHA-1 that have the same hash.

Therefore, if hash(A) == hash(B), then you can be confident that A == B. If you copy a huge file and the hashes of both the original and the copy are the same, then you can be pretty sure that the file is intact.

这篇关于Python SHA1 DECODE函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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