I want to convert this c# code to python. I want to do SHA256 hashing with utf-8 encoding like c# code. But when I print results, they are different (results are in comment lines). What is the point I miss?
From:
//C# code
string passw = "value123value";
SHA256CryptoServiceProvider sHA256 = new SHA256CryptoServiceProvider();
byte[] array = new byte[32];
byte[] sourceArray = sHA256.ComputeHash(Encoding.UTF8.GetBytes(passw));
Console.WriteLine(Encoding.UTF8.GetString(sourceArray)); //J�Q�XV�@�?VQ�mjGK���2
To:
#python code
passw = "value123value"
passw = passw.encode('utf8') #convert unicode string to a byte string
m = hashlib.sha256()
m.update(passw)
print(m.hexdigest()) #0c0a903c967a42750d4a9f51d958569f40ac3f5651816d6a474b1f88ef91ec32