我应该如何为此编写解密程序?

发布于 2025-01-15 05:25:14 字数 1147 浏览 2 评论 0原文

我正在尝试使用Python 编写解密代码。加密工作并在名为 myfile 的文件中输出以下 119105108108 116104105115 11911111410763 ,其中包含“这有效吗?”。但我不知道如何解密它,也不知道它是否可以解密,希望得到一些帮助。

#declare variables
fo = 0
ascii_val = []
asci_val = []
asc_val = []
listtostr = 0
listtost = 0
listtos = 0
split_val = 0
x = 0

#open files
fo = open("myfile.txt","r")
fo1 = open("hora.txt","w")

#read text from files and put into a list    
txt = fo.read()
split_val = txt.split(" ")
print(split_val)

#process of encrypting using ascii values
for x in split_val[0]:
    y = x.split()
    a = ord(x)
    a =str(a)
    ascii_val.append(a)
    
print()

#process
for x in split_val[1]:
    a = ord(x)
    a =str(a)
    asci_val.append(a)
    
print()

#process
for x in split_val[2]:
    a = ord(x)
    a =str(a)
    asc_val.append(a)
    
#joining ascii values together
listtostr = "".join([str(x) for x in ascii_val])

listtost = "".join([str(x) for x in asci_val])

listtos = "".join([str(x) for x in asc_val])

#joining all of the ascii values together
b = listtostr + " " + listtost +" " + listtos
print(b)

#writing to new file
fo1.write(b)

#close files
fo.close()
fo1.close()

I am trying to write an decryption code using Python. The encryption works and outputs the following 119105108108 116104105115 11911111410763 for the words "will this work? in a file called myfile. But i have no idea how to decrypt it or whether it can even be decrypted and would love some help.

#declare variables
fo = 0
ascii_val = []
asci_val = []
asc_val = []
listtostr = 0
listtost = 0
listtos = 0
split_val = 0
x = 0

#open files
fo = open("myfile.txt","r")
fo1 = open("hora.txt","w")

#read text from files and put into a list    
txt = fo.read()
split_val = txt.split(" ")
print(split_val)

#process of encrypting using ascii values
for x in split_val[0]:
    y = x.split()
    a = ord(x)
    a =str(a)
    ascii_val.append(a)
    
print()

#process
for x in split_val[1]:
    a = ord(x)
    a =str(a)
    asci_val.append(a)
    
print()

#process
for x in split_val[2]:
    a = ord(x)
    a =str(a)
    asc_val.append(a)
    
#joining ascii values together
listtostr = "".join([str(x) for x in ascii_val])

listtost = "".join([str(x) for x in asci_val])

listtos = "".join([str(x) for x in asc_val])

#joining all of the ascii values together
b = listtostr + " " + listtost +" " + listtos
print(b)

#writing to new file
fo1.write(b)

#close files
fo.close()
fo1.close()

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文