Download CaesarSQLDB/caesarhash.py from palondomus/CaesarAIContractQATest: direct link, hf CLI and curl.
- Browser
- Download file 2.05 kB
-
https://huggingface.co/palondomus/CaesarAIContractQATest/resolve/main/CaesarSQLDB/caesarhash.py
- Command line
-
hf download hf://palondomus/CaesarAIContractQATest/CaesarSQLDB/caesarhash.py
-
curl -L -o caesarhash.py https://huggingface.co/palondomus/CaesarAIContractQATest/resolve/main/CaesarSQLDB/caesarhash.py
2.05 kB
| import hashlib | |
| import uuid | |
| class CaesarHash: | |
| 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 | |
| def hash_text(text): | |
| """ | |
| Basic hashing function for a text. | |
| """ | |
| return hashlib.sha256(text.encode()).hexdigest() | |
| 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() | |
| 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__": | |
| # qpsignup - 82d7dc19d97ef3e5ffb6917ae5586d5090a489f16b9cca34250223cf6bef6583 | |
| # GoogleAI:amari.lawal05@gmail.com | |
| #print(CaesarHash.hash_text("GoogleAI" + ":" + "amari.lawal05@gmail.com")) | |
| #fields = ("quoter","quotatitle","quotatype","thumbnail","description","visibility","quoterkey","thumbnailfiletype","quotahash") | |
| #value = ('GoogleAI', 'CaesarAI', 'A.I Assistant', b'image here', 'data:image/jpeg;base64,', 'd6bc8ca9302d5cb923f267833a666c20920672b5728ff162cf7d2de282999721') | |
| 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) | |
| #print(CaesarHash.hash_text("amari.lawal@gmail.com")) |