简体   繁体   English

Python SHA1 DECODE函数

[英]Python SHA1 DECODE function

I cant find how to decode string encoded in sha1. 我找不到如何解码在sha1中编码的字符串。 I'm suprised that i can't find simple function in python docs or google doing sha1 decoding. 我很惊讶我找不到在python docs或google中进行sha1解码的简单函数。 I give up. 我放弃。 I need help.. 我需要帮助..

SHA1 is a hashing algorithm. SHA1是一种哈希算法。 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. 1234将散列到1 + 2 + 3 + 4 = 10 ,但这样会432119005050 ,以及许多其他的数字。 Given just the hash value of 10 , you can't tell whether the input was 1234 or 5050 because information was lost. 仅给出哈希值10 ,您就无法确定输入是1234还是5050因为信息丢失了。

Here's a graphical example: 这是一个图形示例:

在此处输入图片说明

As you can see, both John Smith and Sandra Dee are mapped to 02 . 如您所见, John SmithSandra Dee都映射到02 This means that you can't recover which name was hashed given only 02 . 这意味着仅给定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. 仅花了6500个CPU年的时间就发现 SHA-1的一对输入具有相同的哈希值。

Therefore, if hash(A) == hash(B) , then you can be confident that A == B . 因此,如果hash(A) == hash(B) ,那么您可以确定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. 如果您复制一个巨大的文件,并且原始副本和副本的哈希值都相同,则可以确定该文件是完整的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM