Commit 7bc058ce by BellCodeEditor

save project

parent 623fb1a6
Showing with 38 additions and 3 deletions
"""
请使用turtle模块画出五角星
"""
import random
import turtle
screen=turtle.Screen()
screen.bgcolor('green')
pen=turtle.Pen()
colors=['red','yellow','blue']
#私钥
key='2010我家庭生活的开始!¥#@'
#实现交互效果,需要加密的语句或输入你想要加密的文字
message=screen.textinput('温馨提示','你想要加密的文字?')
#加密后的语句
key_message=''
#加入的干扰符
noise='@#$^&**'
#加密过程
for i in message:
str1=i
str2=random.choice(key)
str3=random.choice(key)
#加密后的信息是由一个需要加密的字加上随机出现在秘钥里面的两个字组成
text=str1+str2+str3
#新信息要自增
key_message=key_message+text
#把加密后的文字变更成为列表格式
list_message=list(key_message)
#获取列表的随机索引
index=random.randint(0,len(list_message))
#随机位置插入干扰信息
list_message.insert(index,noise)
#由此产生新的加密信息,为列表格式,转换成字符串
result_message=''.join(list_message)
#打印新的机密信息
#print(result_message)
pen.up()
pen.goto(-220,198)
pen.write(result_message,font=('Times',20,'normal'))
pen.hideturtle()
turtle.done()
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