这样是不行的
echo -n "hello" | sha256sum | sha256sum
因为sha256sum的输出有干扰内容
ppl@de:~/tmp$ echo -n "hello" | sha256sum
2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 -
需要这样子
echo -n "hello" | sha256sum | xxd -r -p | sha256sum
python算法:
#!/usr/bin/env python3
import sys, hashlib, binascii
filename=sys.argv[1]
f = open(filename, 'r')
for line in f:
line = line.replace('\n', '').replace('\r', '')
round1hex = hashlib.sha256(line.encode('utf-8')).hexdigest().zfill(64)
round1bin = binascii.unhexlify(round1hex)
round2hex = hashlib.sha256(round1bin).hexdigest().zfill(64)
print(round2hex)