Commit c8ed453a by BellCodeEditor

auto save

parent e2d46d44
Showing with 26 additions and 0 deletions
import random
# 私钥
key = "abcdefgh使用编程实现位移替换加密,制作密码机关真是太好玩了哈哈!"
# 要加密语句
message = input("请输入你想加密的语句:")
g_message = "port:@#$%^&*"
key_message = ""
# 请使用私钥key,对message进行加密
for i in message:
str1 = i; #要加密的字符
str2 = random.choice(key) #在密钥中随机抽取的一个字符
str3 = random.choice(key) #在密钥中随机抽取的一个字符
text = str1 + str2 + str3 #把要加密的字符拼接上两个随机字符
key_message = key_message + text #把加密好的字符串保存起来
li = list(key_message) #把字符串转为列表
w = random.randint(1,len(key_message)-1)
li.insert(w,g_message) #使用列表的插入方式把干扰字符插入进去
key_message = "".join(li)
print(key_message)
\ 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