tom.hostyn
BAN USERIn general, different permutations will have different hashes.
E.g hash("baaann") != hash("banana")
however, there are indeed corner cases such as
hash ("baanna") == hash ("banana")
btw - edited the code to ensure we modulo the sum, not the last term
The input can be combined with the reverse input by summing their ascii values. this string can then be hashed with a standard hash function. in python:
import hashlib
def reversable_hash(s):
tmp = []
for i in range(len(s)):
tmp += [chr((ord(s[i]) + ord(s[len(s) -i -1])) % 255)]
tmp = ''.join(tmp)
return hashlib.md5(tmp.encode('utf8')).hexdigest()
yields:
% reversable_hash("banana")
3210b46e29e61d8865edf62e65929b76
% reversable_hash("ananab")
3210b46e29e61d8865edf62e65929b76
% reversable_hash("anaaab")
9009f73b1797b4c5f6851cf4865c5895
% reversable_hash("élève")
7b27c8eb83ab0aaa267352caaf0bea41
% reversable_hash("evèlé")
7b27c8eb83ab0aaa267352caaf0bea41
% reversable_hash("012")
08f8e0260c64418510cefb2b06eee5cd
% reversable_hash("210")
08f8e0260c64418510cefb2b06eee5cd
RepPatriciaNRowe, Consultant at ADP
Hi i am a Freelance Writer and Social Media Manager who helps finance professionals and Fin-tech startups build an audience ...
with +, do you mean string concatination ? That would yield different hash values.
- tom.hostyn March 16, 2018