|
|
import hashlib |
|
|
import uuid |
|
|
|
|
|
class CaesarHash: |
|
|
@staticmethod |
|
|
def hash_text_auth(text): |
|
|
""" |
|
|
Basic hashing function for a text using random unique salt. |
|
|
""" |
|
|
salt = uuid.uuid4().hex |
|
|
return hashlib.sha256(salt.encode() + text.encode()).hexdigest() + ':' + salt |
|
|
@staticmethod |
|
|
def hash_text(text): |
|
|
""" |
|
|
Basic hashing function for a text. |
|
|
""" |
|
|
return hashlib.sha256(text.encode()).hexdigest() |
|
|
@staticmethod |
|
|
def match_hashed_text(hashedText, providedText): |
|
|
""" |
|
|
Check for the text in the hashed text |
|
|
""" |
|
|
_hashedText, salt = hashedText.split(':') |
|
|
return _hashedText == hashlib.sha256(salt.encode() + providedText.encode()).hexdigest() |
|
|
@staticmethod |
|
|
def hash_quota(data:dict): |
|
|
hashinput = data["quotatitle"].lower().replace(" ","",100) + data["quotatype"].lower().replace(" ","",100) |
|
|
quotahash = CaesarHash.hash_text(hashinput) |
|
|
return quotahash |
|
|
if __name__ == "__main__": |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
text = "" |
|
|
|
|
|
for i in ["86c8a9f00ff799e13202b79bed230368707369107729b344903632073c22ad40","a4fc8fd49a8c84a40d91c7a0f3927291556ab6fe717e5754dbb017181e6943d7"]: |
|
|
|
|
|
text += f"emailhash = '{i}'" |
|
|
text += " OR " |
|
|
finaltext = text[:text.rfind("OR")].strip() |
|
|
from caesarcrud import CaesarCRUD |
|
|
caesarcrud = CaesarCRUD() |
|
|
res = caesarcrud.get_data(("email",),"contributors",finaltext) |
|
|
print(res) |
|
|
print(finaltext) |
|
|
|
|
|
|