Commit 8a3e171d by BellCodeEditor

auto save

parent 1c197d62
Showing with 20 additions and 20 deletions
import random
message="周末上课开心吗?" # 要加密的内容
key="姜锴和刘俊贤今天下午两点要参加python一级等考。" # 密钥
ni="$%^&*#()" # 干扰字符
new="" # 创建一个空字符串,用于保存每一次加密之后的结果
for i in message:
str=i # 把从message中取出来的每一个字符都存放到str变量里
str1=random.choice(key) # 从key中随机抽取一个字符
str2=random.choice(key)
text=str+str1+str2
new=new+text
new_list=list(new) # 用list()将字符串new转换为列表
new_list.insert(7,ni)
print("".join(new_list))
import random
# 私钥
key = "abcdefgh使用编程实现位移替换加密,制作密码机关真是太好玩了哈哈!"
# 要加密语句
message = "诺依,周末一起去看动漫展吧!"
key_message=""
# 请使用私钥key,对message进行加密
for i in range(len(message)):
a=message[i]
b=random.choice(key)
c=random.choice(key)
d=a+b+c
key_message=key_message+d
print(key_message)
message1=list(key_message)
message1.insert(random.randint(0,len(message1)),"¥%……&*$%_*^&%(%^")
message2="".join(message1)
print(message2)
\ No newline at end of file
# list() 用于将一个字符串序列转换为列表
# 也可以用于创建一个新列表
a='sdfdsjfhery3'
print(list(a))
\ 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