FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
fastapi-admin/fastapi_admin/utils.py at dev · stonegithubs/fastapi-admin · GitHub
stonegithubs
fastapi-admin
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
fastapi-admin
/
fastapi_admin
/
utils.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
23 lines (16 loc) · 518 Bytes
Breadcrumbs
fastapi-admin
/
fastapi_admin
/
utils.py
Copy path
File metadata and controls
23 lines (16 loc) · 518 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import
random
import
string
import
bcrypt
def
generate_random_str
(
length
:
int
,
is_digit
:
bool
=
True
,
):
if
is_digit
:
all_char
=
string
.
digits
else
:
all_char
=
string
.
ascii_letters
+
string
.
digits
return
""
.
join
(
random
.
sample
(
all_char
,
length
))
def
check_password
(
password
:
str
,
password_hash
:
str
):
return
bcrypt
.
checkpw
(
password
.
encode
(),
password_hash
.
encode
())
def
hash_password
(
password
:
str
):
return
bcrypt
.
hashpw
(
password
.
encode
(),
bcrypt
.
gensalt
()).
decode
()
Back
|
FazBrowse Home
|
New Git URL