gpt4 book ai didi

python - 将大数转换为字符 - Python

转载 作者:行者123 更新时间:2023-11-30 22:45:43 24 4
gpt4 key购买 nike

我有一门密码学类(class),我将在其中解密 RSA 芯片。现在,解密完成后,我想将解密列表(decryptList[])中的每个数字转换为字符,以便文本可读。

在decryptList[0]中,我有138766332635707196740445712245626646062。我应该如何将此数字转换为可读文本?

我尝试从字符串转换为整数:

plainText = "stackoverflow".encode('hex')
plainInt = long(plainText,16)
print plainInt
=> 9147256685580292608768854486903

现在我想从 plainInt 转到“stackoverflow”。有什么建议我应该如何实现这一点?

最佳答案

这适用于 python 2 和 3

import codecs
b = hex(plainInt).rstrip("L").lstrip("0x")
codecs.decode(b, 'hex').decode('utf-8')

关于python - 将大数转换为字符 - Python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41123816/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com