Python单向哈希加密计算

Python单向哈希加密计算

#Python forensics
#Simple program to generate the SHA-256
#one-way cryptographic hash of a given string

#Step 1
#Instruct the interpreter to import the Standard library module hashlib

import hashlib
#print a message to the user

print
print("Simple program to generate the SHA-256 Hash of the String 'Pyhton forensics'")
print

#define a string with the desired text
myString = 'Pythonforensics'

#create an object named hash which is of type sha256
Hash = hashlib.sha256()

#utilize the up data method of the hash object to generate the SHA256 hash of myString
#SHA256 hash of myString
Hash.update(myString.encode('utf8'))

#obtain the generated hex values of the SHA256 Hash from the object by utilizing the hexdigest method
hexSHA256 = Hash.hexdigest()

#print out the result and utilize the upper method to convert all the hex characters to uppercase
print("SHA-256Hash:" + hexSHA256.upper())
print

print('Processingcompleted')

输出结果:
Simple program to generate the SHA-256 Hash of the String ‘Pyhton forensics’
SHA-256Hash:00CF3CD9AB91D70EC48133F91690DB1E6C24AD4F82FBABDB22B189B2A45351F5
Processingcompleted

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值