Skip to content
Advertisement

How to reproduce the behavior of SQL NVARCHAR in Python when generating a SHA-512 hash?

I have the following SQL query

that generates the hash value

out of todays date and I want to reproduce this hash in Python with

but I get

as hash value. When I use VARCHAR instead of NVARCHAR I get the correct hash value. How can I reproduce the bahavior of NVARCHAR in Python?

Advertisement

Answer

NVARCHAR encodes to UTF-16LE. Adding it to

creates the correct hash value.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement