UtoljĂĄra aktĂ­v 8 months ago

甹 bcrypt é€ČèĄŒćŻ†çąŒćŠ ćŻ†èˆ‡é©—è­‰ïŒŒæ”ŻæŽ salt、è‡Ș拕漉慹雜æčŠïŒŒäżè­·äœ çš„äœżç”šè€…èł‡æ–™äžèą«çˆ†ç ŽïŒé©ćˆç™»ć…„é©—è­‰èˆ‡ćžłè™Ÿçł»ç”± 🚀

timmy gist felĂŒlvizsgĂĄlĂĄsa 8 months ago. RevĂ­ziĂłhoz ugrĂĄs

Nincsenek vĂĄltoztatĂĄsok

timmy gist felĂŒlvizsgĂĄlĂĄsa 9 months ago. RevĂ­ziĂłhoz ugrĂĄs

1 file changed, 18 insertions

bcrypt_util.py(fåjl létrehozva)

@@ -0,0 +1,18 @@
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:
11 + return bcrypt.checkpw(password.encode(), hashed.encode())
12 +
13 +
14 + if __name__ == "__main__":
15 + password = "super secret password"
16 + hashed = encode_password(password)
17 + print(hashed)
18 + print(check_password(password, hashed))
Újabb RĂ©gebbi