Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson7_4
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
cbd6a4b5
authored
Nov 22, 2020
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
778981d1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
12 deletions
diy4.py
diy4.py
View file @
cbd6a4b5
...
@@ -3,22 +3,21 @@ import random
...
@@ -3,22 +3,21 @@ import random
# 私钥
# 私钥
key
=
"abcdefgh使用编程实现位移替换加密,制作密码机关真是太好玩了哈哈!"
key
=
"abcdefgh使用编程实现位移替换加密,制作密码机关真是太好玩了哈哈!"
# 要加密语句
# 要加密语句
message
=
input
(
"
请输入密文
"
)
message
=
input
(
""
)
text
=
""
#text是一个字符串变量 空的
# 请使用私钥key,对message进行加密
# 请使用私钥key,对message进行加密
pri_message
=
""
for
i
in
message
:
for
i
in
message
:
str1
=
i
str1
=
i
str2
=
random
.
choice
(
key
)
str2
=
random
.
choice
(
key
)
str3
=
random
.
choice
(
key
)
str3
=
random
.
choice
(
key
)
text
=
str1
+
str2
+
str3
text
=
text
+
str1
+
str2
+
str3
pri_message
=
pri_message
+
text
#
pri_message = pri_message + text
message2
=
list
(
pri_message
)
##############注意以下的代码
key2
=
"port:hkjleldfngls[]
"
str4
=
"port:jhdva;dlbksb231.OP{:
"
ls
=
list
(
text
)
#将 字符串变量text 转化为列表 ,并赋值给变量 ls
message2
.
insert
(
random
.
randint
(
0
,
10
),
key2
)
ls
.
insert
(
random
.
randint
(
0
,
len
(
ls
)),
str4
)
#将干扰字符串str4 插入列表变量ls的第三位置3
#重新转换为字符串
pri_message2
=
""
.
join
(
message2
)
text2
=
""
.
join
(
ls
)
#将列表ls当中的元素组合起来,变成一个字符串,并将该字符串赋值给变量 text2
print
(
pri_message
2
)
print
(
text
2
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment