有一条消息:0x1a67cad23ff2c5752f3d652d302a46427a27d5017a8064b32329ec1871L
和用于加密的python代码:
import codecs
def bytes_to_long(data):
return int(data.encode("hex"), 16)
def rsa_encrypt(msg, e, n):
return pow(bytes_to_long(msg), e, n)
def main():
n = 29819592777931214269172453467810429868925511217482600306406141434158090
e = 65537
secret = "" #find this
with codecs.open("encrypted.txt", "w") as output_file:
output_file.write(hex(rsa_encrypt(secret, e, n)))
main()
目标是找到用于生成secret
的变量0x1a67cad23ff2c5752f3d652d302a46427a27d5017a8064b32329ec1871L
我迈出了一小步:
>>> s = '0x1a67cad23ff2c5752f3d652d302a46427a27d5017a8064b32329ec1871'
>>> int(s, 16)
>>> `711889215226322184943193282945958342309634097071492255020318494300273L`
但我不确定我是不是很好。我想有一些关于codecs
模块或encode
函数属性的技巧,但是我被卡住了,不知道如何继续前进。