Problem with hashlib

0

I have a problem with using 'hashlib' from python, since I'm comparing the hashes generated with the line below, with the hashes generated on the site: ' link ', but when comparing the results I see they are different.

Code used to generate hashs:

def encoding(hash_test):
    return hashlib.sha512(bytes(hash_test, encoding='UTF-16LE')).hexdigest()

Note: I used the python documentation code ( link ) to build this one.

Hash generated by code:

  

3a94b49c382f9c39a83e0ae31a26bdcf23f74b6c81eb8779f1305b840aaabc94e3921d6f9d0e25b15f6569c42dc24f9524540b765147699e33d903dc6a85a354

Hash generated by site:

  

b123e9e19d217169b981a61188920f9d28638709a5132201684d792b9264271b7f09157ed4321b1c097f7a4abecfc0977d40a7ee599c845883bd1074ca23c4af

Note: I have used the word 'test' on both site and code to generate the hashes.

What's wrong with the code so the results are different?

    
asked by anonymous 06.09.2017 / 19:50

1 answer

0

Code:

import hashlib


def hash_sha512( text ):
    return hashlib.sha512( text.encode('utf-8') ).hexdigest()

print hash_sha512( "teste" )

Output:

  

b123e9e19d217169b981a61188920f9d28638709a5132201684d792b9264271b7f09157ed4321b1c097f7a4abecfc0977d40a7ee599c845883bd1074ca23c4af

    
06.09.2017 / 21:25