Initial Commit
This commit is contained in:
0
ripple/__init__.py
Normal file
0
ripple/__init__.py
Normal file
39
ripple/passwordUtils.py
Normal file
39
ripple/passwordUtils.py
Normal file
@@ -0,0 +1,39 @@
|
||||
#import crypt
|
||||
#import base64
|
||||
import bcrypt
|
||||
|
||||
def checkOldPassword(password, salt, rightPassword):
|
||||
"""
|
||||
Check if `password` + `salt` corresponds to `rightPassword`
|
||||
NOT USED ANYMORE! RETURNS ALWAYS FALSE!
|
||||
|
||||
:param password: input password
|
||||
:param salt: password's salt
|
||||
:param rightPassword: tight password
|
||||
:return: True if the password is correct, otherwise False.
|
||||
"""
|
||||
return False
|
||||
#return (rightPassword == crypt.crypt(password, "$2y$"+str(base64.b64decode(salt))))
|
||||
|
||||
def checkNewPassword(password, dbPassword):
|
||||
"""
|
||||
Check if a password (version 2) is right.
|
||||
|
||||
:param password: input password
|
||||
:param dbPassword: the password in the database
|
||||
:return: True if the password is correct, otherwise False.
|
||||
"""
|
||||
if len(password) != 32:
|
||||
return False
|
||||
password = password.encode("utf-8")
|
||||
dbPassword = dbPassword.encode("utf-8")
|
||||
return bcrypt.checkpw(password, dbPassword)
|
||||
|
||||
def genBcrypt(password):
|
||||
"""
|
||||
Bcrypts a password.
|
||||
|
||||
:param password: the password to hash
|
||||
:return: bytestring
|
||||
"""
|
||||
return bcrypt.hashpw(password.encode("utf8"), bcrypt.gensalt(10, b'2a'))
|
64
ripple/scoreUtils.py
Normal file
64
ripple/scoreUtils.py
Normal file
@@ -0,0 +1,64 @@
|
||||
from common.constants import mods
|
||||
|
||||
|
||||
def isRankable(m):
|
||||
"""
|
||||
Checks if `m` contains unranked mods
|
||||
|
||||
:param m: mods enum
|
||||
:return: True if there are no unranked mods in `m`, else False
|
||||
"""
|
||||
# TODO: Check other modes unranked mods ...?
|
||||
return not ((m & mods.RELAX2 > 0) or (m & mods.AUTOPLAY > 0) or (m & mods.SCOREV2 > 0))
|
||||
|
||||
def readableGameMode(gameMode):
|
||||
"""
|
||||
Convert numeric gameMode to a readable format. Can be used for db too.
|
||||
|
||||
:param gameMode:
|
||||
:return:
|
||||
"""
|
||||
# TODO: Same as common.constants.gameModes.getGameModeForDB, remove one
|
||||
if gameMode == 0:
|
||||
return "std"
|
||||
elif gameMode == 1:
|
||||
return "taiko"
|
||||
elif gameMode == 2:
|
||||
return "ctb"
|
||||
else:
|
||||
return "mania"
|
||||
|
||||
def readableMods(m):
|
||||
"""
|
||||
Return a string with readable std mods.
|
||||
Used to convert a mods number for oppai
|
||||
|
||||
:param m: mods bitwise number
|
||||
:return: readable mods string, eg HDDT
|
||||
"""
|
||||
r = ""
|
||||
if m == 0:
|
||||
return "nomod"
|
||||
if m & mods.NOFAIL > 0:
|
||||
r += "NF"
|
||||
if m & mods.EASY > 0:
|
||||
r += "EZ"
|
||||
if m & mods.HIDDEN > 0:
|
||||
r += "HD"
|
||||
if m & mods.HARDROCK > 0:
|
||||
r += "HR"
|
||||
if m & mods.DOUBLETIME > 0:
|
||||
r += "DT"
|
||||
if m & mods.HALFTIME > 0:
|
||||
r += "HT"
|
||||
if m & mods.FLASHLIGHT > 0:
|
||||
r += "FL"
|
||||
if m & mods.SPUNOUT > 0:
|
||||
r += "SO"
|
||||
if m & mods.TOUCHSCREEN > 0:
|
||||
r += "TD"
|
||||
if m & mods.RELAX > 0:
|
||||
r += "RX"
|
||||
if m & mods.RELAX2 > 0:
|
||||
r += "AP"
|
||||
return r
|
1273
ripple/userUtils.py
Normal file
1273
ripple/userUtils.py
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user