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
8a3e171d
authored
Mar 09, 2025
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
1c197d62
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
20 deletions
620.py
diy4.py
620.py
0 → 100644
View file @
8a3e171d
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
))
diy4.py
View file @
8a3e171d
import
random
# list() 用于将一个字符串序列转换为列表
# 也可以用于创建一个新列表
# 私钥
a
=
'sdfdsjfhery3'
key
=
"abcdefgh使用编程实现位移替换加密,制作密码机关真是太好玩了哈哈!"
print
(
list
(
a
))
# 要加密语句
\ No newline at end of file
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
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