简体   繁体   English

在Python中将SHA256哈希字符串转换为SHA256哈希对象

[英]Convert SHA256 hash string to SHA256 hash object in Python

I have a string which is a SHA256 hash, and I want to pass it to a Python script which will convert it to a SHA256 object. 我有一个字符串,它是一个SHA256哈希,我想将其传递给Python脚本,该脚本会将其转换为SHA256对象。 If I do this: 如果我这样做:

my_hashed_string = // my hashed string here
m = hashlib.SHA256()
m.update( my_hashed_string  )

it will just hash my hash. 它只会哈希我的哈希。 I don't want to hash twice...it's already been hashed. 我不想哈希两次...它已经被哈希了。 I just want python to parse my original hashed string as a hash object. 我只希望python将我原始的哈希字符串解析为哈希对象。 How do I do this? 我该怎么做呢?

Unfortunately the hash alone isn't enough info to reconstruct the hash object. 不幸的是,仅散列还不足以重建散列对象。 The hash algorithm itself is temporal, depending on both internal structures and further input in order to generate hashes for subsequent input; 哈希算法本身是时间的,取决于内部结构和其他输入,以便为后续输入生成哈希。 the hash itself is only a small piece of the cross section of the algorithm's data, and cannot alone be used to generate hashes of additional data. 散列本身只是算法数据横截面的一小部分,不能单独用于生成其他数据的散列。

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

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