import math
ch = input("请输入一个字符:")
#原始长度
str = ''
for i in range(len(ch)):
chvalue = ord(ch[i])
binary = bin(int(chvalue))[2:].zfill(8)
str = str + binary
#消息长度设置
lengthbit = ''
lengthbit = (64-len(bin(len(str))[2:]))*'0' + bin(len(str))[2:]
#lengthbit = (64-len(bin(len(str))[2:]))*'0' + [0]
#填充长度
N=math.ceil(len(str)/512)
fillbit = '1'+(512 * N - 64-len(str)-1) * '0'
#长度=原始+填充+消息
md5str = str +fillbit + lengthbit
hexmd5str = hex(int(md5str,2))[2:]
print('md5str', md5str)
print('hexmd5str', hexmd5str)