How to hash in python an equivalent of the following (changing the sql part isn't possible, only to mimic the behavior in python):
SELECT HASHBYTES('SHA2_256', FORMAT(1234, ''))
output: 0x4F37C061F1854F9682F543FECB5EE9D652C803235970202DE97C6E40C8361766
which is different than:
SELECT HASHBYTES('SHA2_256','1234')
SELECT HASHBYTES('SHA2_256',CAST(1234 as VARCHAR(100)))
output: 0x03AC674216F3E15C761EE1A5E255F067953623C8B388B4459E13F978D7C846F4
How to achieve in python the first output? Currently:
from hashlib import sha256
sha256('1234'.encode()).hexdigest().upper()
output: 03AC674216F3E15C761EE1A5E255F067953623C8B388B4459E13F978D7C846F4