Commit 57ac4549 by BellCodeEditor

save project

parent 41fa7c36
Showing with 8 additions and 4 deletions
...@@ -2,9 +2,10 @@ import random ...@@ -2,9 +2,10 @@ import random
# 私钥 # 私钥
key = "abcdefgh使用编程实现位移替换加密,制作密码机关真是太好玩了哈哈!" key = "abcdefgh使用编程实现位移替换加密,制作密码机关真是太好玩了哈哈!"
# 要加密语句
message = "诺依,周末一起去看动漫展吧!"
key2 = "%^*&*" key2 = "%^*&*"
# 要加密语句
message = input("请输入要加密的语句:")
# 请使用私钥key,对message进行加密 # 请使用私钥key,对message进行加密
text = "" text = ""
...@@ -20,7 +21,9 @@ for c in message: ...@@ -20,7 +21,9 @@ for c in message:
#2.通过列表的insert函数,将第二个密钥插入列表的任意位置 #2.通过列表的insert函数,将第二个密钥插入列表的任意位置
#3.通过"".join()方法将列表转换为字符串 #3.通过"".join()方法将列表转换为字符串
li_text = list(text) li_text = list(text)
li_text.insert(5,key2) #通过随机数,选取一个位置,此位置的范围是0-被加密数据的最大长度
num = random.randint(0,len(li_text))
li_text.insert(num,key2)
#jion连接 #jion连接
text = "".join(li_text) text = "".join(li_text)
print(text) print(text)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment