bash 双hash算法sha256的写法

这样是不行的

复制代码
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)

Blockchain Demo

相关推荐
临床数据科学和人工智能兴趣组10 小时前
在R语言中, 使用 as.factor() 函数转换数值型变量
开发语言·r语言
andyweike13 小时前
php笔记
开发语言·笔记·php
Circ.14 小时前
Python 调试 Litellm 本地大模型接口:模型列表与对话接口实操踩坑记录
开发语言·python
现任明教教主~15 小时前
Thinkphp站群蜘蛛池SaaS系统YanyvSEO含多用户/积分/六大引擎计费/易支付对接
java·开发语言·spring
Zhou14113616 小时前
SpringSecurity_02_授权与高级功能
开发语言·python
码匠许师傅16 小时前
【C++三方组件】cpp-httplib:一个头文件起 HTTP 服务
开发语言·c++·http
小小小小钰儿18 小时前
1.5-Python网络编程
开发语言·网络·python·web安全·计算机·网络安全
hiahiahia12318 小时前
实现完整 Tool Dispatcher
开发语言·前端