Download app/utils/auth_tools.py from gitdeem/dt: direct link, hf CLI and curl.
- Browser
- Download file 740 Bytes
-
https://huggingface.co/spaces/gitdeem/dt/resolve/main/app/utils/auth_tools.py
- Command line
-
hf download hf://spaces/gitdeem/dt/app/utils/auth_tools.py
-
curl -L -o auth_tools.py https://huggingface.co/spaces/gitdeem/dt/resolve/main/app/utils/auth_tools.py
740 Bytes
| #========== utils/auth_tools.py ========== | |
| import random | |
| from datetime import datetime, timedelta | |
| from werkzeug.security import generate_password_hash, check_password_hash | |
| def generate_code(length=6): | |
| """ηζζ°ειͺθ―η """ | |
| return ''.join(random.choices('0123456789', k=length)) | |
| def validate_code(code_record): | |
| """ιͺθ―η ζζζ§ζ£ζ₯""" | |
| if not code_record: | |
| return False | |
| return (datetime.utcnow() - code_record.created_at) < timedelta(seconds=1800) | |
| def hash_password(password): | |
| """ε―η εεΈε€η""" | |
| return generate_password_hash(password) | |
| def check_password(hashed_password, password): | |
| """ε―η ζ ‘ιͺ""" | |
| return check_password_hash(hashed_password, password) |