simple-hash_2.py 288 B

1234567891011121314
  1. def hash_pwd (string, salt=None):
  2. msg = []
  3. if salt == None:
  4. salt = gen_salt(20)
  5. for i, c in enumerate(string):
  6. char_s = ord(salt[len(string) - i])
  7. char_string = ord(c)
  8. msg.append(chr((char_s + char_string) % 127))
  9. res = ''.join(msg)
  10. return (res + salt, salt)