reborked the token system
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import random
|
||||
import string
|
||||
import base64
|
||||
from Crypto.Cipher import AES
|
||||
import hashlib
|
||||
@@ -44,6 +46,12 @@ def get_direct_token(share, filename):
|
||||
)
|
||||
|
||||
|
||||
def has_token(token, share):
|
||||
if not 'tokens' in share:
|
||||
return False
|
||||
return token in share['tokens']
|
||||
|
||||
|
||||
def password_hash(string, salt=""):
|
||||
if type(string) == str:
|
||||
string = string.encode("utf-8")
|
||||
@@ -54,6 +62,12 @@ def password_hash(string, salt=""):
|
||||
).hexdigest()
|
||||
|
||||
|
||||
def random_token():
|
||||
chars = [random.choice(string.ascii_letters + string.digits) for n in range(30)]
|
||||
token = "".join(chars)
|
||||
return token
|
||||
|
||||
|
||||
def remove_pad(string):
|
||||
""" Remove spaces from right """
|
||||
return string.rstrip(" ")
|
||||
|
||||
Reference in New Issue
Block a user