use xxhash
This commit is contained in:
parent
5c29ebd821
commit
6ec575810a
5 changed files with 42 additions and 26 deletions
24
script/adduser.py
Normal file
24
script/adduser.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
import collections
|
||||
from pymongo import MongoClient
|
||||
from dotenv import load_dotenv
|
||||
from os import getenv
|
||||
import xxhash
|
||||
import getpass
|
||||
|
||||
load_dotenv()
|
||||
client=MongoClient(getenv("MONGO"))
|
||||
db = client.get_database(getenv("DB"))
|
||||
|
||||
def add_user():
|
||||
username = input('username ? ')
|
||||
password = getpass.getpass('password ? ')
|
||||
pass_retry = getpass.getpass('Re-type your password ? ')
|
||||
if password != pass_retry:
|
||||
print("not correct password.")
|
||||
add_user()
|
||||
hashed_pass = xxhash.xxh64(password, 5).hexdigest()
|
||||
collection = db["users"]
|
||||
print(f"username: {username}, password: {hashed_pass}")
|
||||
collection.update_one({ "name": username}, { "$set": {"pass": hashed_pass}})
|
||||
|
||||
add_user()
|
Loading…
Add table
Add a link
Reference in a new issue