在Python中更改哈希的内部状态

时间:2019-02-15 09:22:30

标签: python sha256

在C程序中,我可以如下更改SHA256算法的内部状态:

SHA256_CTX c;
SHA256_Init(&c);
for (i =0; i<64; i++)
    SHA256_Update(&c, "$", 1);

# 0x44332211 is just for example
c.h[0] = htole32(0x44332211);
c.h[1] = htole32(0x44332211);
c.h[2] = htole32(0x44332211);
c.h[3] = htole32(0x44332211);
c.h[4] = htole32(0x44332211);
c.h[5] = htole32(0x44332211);
c.h[6] = htole32(0x44332211);
c.h[7] = htole32(0x44332211);

Python提供了hashlib.sha256。我想问问是否有什么办法可以像在上面的C语言中那样在Python中更新sha256算法的内部状态?

0 个答案:

没有答案