Last active
January 13, 2021 21:27
-
-
Save DiamondDemon669/17dcaf08f2d42aa778bdbf86e8d4d26c to your computer and use it in GitHub Desktop.
Python hashing demonstration. no hashlib or hmac is used to make this. (It is somewhat reversable, but you need either the key or message)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I have decided to call this the ascii hasher | |
# new(msg) generates a hash using a psuedo random number with the encoded message as its seed for the key | |
# new_wkey(key, msg) generates a hash using the key and the message | |
def new_wkey(key, msg): | |
enc_key, enc_msg = int(''.join([str(ord(c)) for c in key])), int(''.join([str(ord(c)) for c in msg])) # Generates encoded key and encoded message | |
added = str(enc_key * enc_msg) # Creates the hash as an integer | |
if len(added) % 3: # Removes irregularities in the hash | |
if len("00" + added) % 3: | |
added = "00" + added | |
else: | |
added = "0" + added | |
split_added = [added[i:i+3] for i in range(0, len(added), 3)] # Splits the hash every three characters | |
final_hash = ''.join([chr(int(i)) for i in split_added]) # Converts hash into string | |
return final_hash | |
def new(msg): | |
enc_msg = int(''.join([str(ord(c)) for c in msg])) # Encodes message | |
key = str((enc_msg * len(msg)) % (len(msg) / enc_msg)) # Generate psuedo random key | |
return new_wkey(key, msg) # Uses new_wkey() function |
EDIT: Completely overhauled the module
EDIT: changed base10 irregularity checker
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
EDIT: removed the two for loops