timmy / 🔐 Python 密碼雜湊教學:用 bcrypt 安全加密與驗證
0 喜欢
0 派生
1 文件
最后活跃于 8 months ago
用 bcrypt 進行密碼加密與驗證,支援 salt、自動安全雜湊,保護你的使用者資料不被爆破!適合登入驗證與帳號系統 🚀
| 1 | import bcrypt |
| 2 | |
| 3 | |
| 4 | def encode_password(password: str) -> str: |
| 5 | salt = bcrypt.gensalt() |
| 6 | hashed = bcrypt.hashpw(password.encode(), salt) |
| 7 | return hashed.decode() |
| 8 | |
| 9 | |
| 10 | def check_password(password: str, hashed: str) -> bool: |
上一页
下一页