1234567891011121314151617181920212223242526272829 |
- def hash_pwd (string, salt=None):
- msg = []
- if salt == None:
- salt = gen_salt(20)
- for i, c in enumerate(string):
- char_s = ord(salt[len(string) - i])
- char_string = ord(c)
- msg.append(chr((char_s + char_string) % 127))
- res = ''.join(msg)
- return (res + salt, salt)
- if __name__ == '__main__':
- print('Password')
- message = input('> ')
- hashed_password, salt = hash_pwd(message)
- print(f'Encryption: {hashed_password}')
- print('Enter password again')
- second_password = input('> ')
- if (hash_pwd(second_password, salt)[0] == hashed_password):
- print('Passwords match! Great!')
- else:
- print('Passwords don\'t match.')
|