我有一门密码学的课程,我要解密一个RSA芯片。现在解密完成后,我想把解密列表(decryptList[])中的每个数字转换成字符,这样文本就可读了。在
在解密列表[0]中,我有138766332635707196740445712245626646062。我该怎么把这个数字转换成可读的文本?在
我试着从字符串变为int:
plainText = "stackoverflow".encode('hex')
plainInt = long(plainText,16)
print plainInt
=> 9147256685580292608768854486903
现在我想从plainInt转到“stackoverflow”。 有什么小贴士可以帮我完成这个任务吗?在
在Python2中,可以执行与将字符串转换为数字相反的操作:
在python3中,int有一个“
^{pr2}$to_bytes
”函数,它采用字节长度和字节顺序(big或littleendian):回答您的示例:使用}从hex获取字符串:
hex
从long向后返回到hex,使用{这适用于Python2和3
相关问题 更多 >
编程相关推荐