Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
P
PDF Reader 2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wanglei
PDF Reader 2
Commits
940e2ce7
Commit
940e2ce7
authored
Oct 29, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
3c81d21e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
test9.py
app/test9.py
+8
-8
No files found.
app/test9.py
View file @
940e2ce7
import
json
import
json
import
os
import
os
import
random
import
re
import
re
import
shutil
import
shutil
from
base64
import
b64encode
,
b64decode
import
cv2
import
cv2
import
numpy
as
np
import
numpy
as
np
import
regex
as
re2
import
regex
as
re2
from
Cryptodome.Cipher
import
AES
from
Cryptodome.Random
import
get_random_bytes
import
string
import
string
import
random
import
random
...
@@ -461,7 +455,9 @@ def get_random_string(length=8, is_ascii=True):
...
@@ -461,7 +455,9 @@ def get_random_string(length=8, is_ascii=True):
global
used_words
# 使用全局变量 used_words
global
used_words
# 使用全局变量 used_words
words
=
load_words_from_file
(
'word_file.json'
)
words
=
load_words_from_file
(
'word_file.json'
)
if
words
:
if
words
:
while
words
:
max_attempts
=
500
# 限制循环次数
attempts
=
0
while
words
and
attempts
<
max_attempts
:
random_word
=
random
.
choice
(
words
)
random_word
=
random
.
choice
(
words
)
if
random_word
not
in
used_words
:
if
random_word
not
in
used_words
:
used_words
.
add
(
random_word
)
used_words
.
add
(
random_word
)
...
@@ -469,8 +465,12 @@ def get_random_string(length=8, is_ascii=True):
...
@@ -469,8 +465,12 @@ def get_random_string(length=8, is_ascii=True):
return
random_word
return
random_word
elif
not
is_ascii
:
elif
not
is_ascii
:
return
random_word
return
random_word
return
None
attempts
+=
1
# 如果单词列表为空或循环次数达到上限,则自动生成随机字符串
first_char
=
random
.
choice
(
string
.
ascii_lowercase
)
rest_chars
=
''
.
join
(
random
.
choice
(
string
.
ascii_lowercase
)
for
_
in
range
(
length
-
1
))
return
first_char
+
rest_chars
def
load_words_from_file
(
file_path
):
def
load_words_from_file
(
file_path
):
...
...
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