-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
218 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from hashlib import md5 | ||
|
||
def md5_digest(s: str) -> str: | ||
# 创建md5对象 | ||
new_md5 = md5() | ||
# 这里必须用encode()函数对字符串进行编码,不然会报 TypeError: Unicode-objects must be encoded before hashing | ||
new_md5.update(s.encode(encoding='utf-8')) | ||
# 加密 | ||
return new_md5.hexdigest() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,4 @@ def main(): | |
application.run() | ||
|
||
if __name__ == "__main__": | ||
main() | ||
main() |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import cookies from 'js-cookie' | ||
import axios from 'axios' | ||
import md5 from 'js-md5' | ||
import { ElMessage } from 'element-plus' | ||
|
||
let password = ""; | ||
|
||
function setPassword(pwd) { | ||
password = pwd; | ||
cookies.set('password', pwd, { expires: 365 }) | ||
} | ||
|
||
function getPassword() { | ||
if (password === "") { | ||
password = cookies.get('password') | ||
} | ||
|
||
if (password === undefined) { | ||
password = ""; | ||
} | ||
|
||
return password; | ||
} | ||
|
||
function clearPassword() { | ||
password = ""; | ||
cookies.remove('password') | ||
window.location.reload(); | ||
} | ||
|
||
function checkPassword(pwd) { | ||
axios.post('/check_password', { | ||
"password": md5(pwd) | ||
}) | ||
.then(function (response) { | ||
if (response.data.code === 0) { | ||
setPassword(pwd); | ||
window.location.reload(); | ||
} else { | ||
ElMessage.error(response.data.message); | ||
} | ||
}) | ||
.catch(function (error) { | ||
console.log(error); | ||
ElMessage.error("Network error"); | ||
} | ||
); | ||
} | ||
|
||
export { | ||
setPassword, | ||
getPassword, | ||
clearPassword, | ||
checkPassword | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters