Open ipconfiger opened 5 years ago
How did you transform the source text? Might be an encoding issue as you need a Uint8List to hash a String.
source text is '1d31dc56a882c686e5355f367d2ea8393ef8535f19896e38c83f025062837e901d0400551802c5533661aabc96135de5eb91a982fdb9ba3a876043b8e883ae50'
Is that the actual text in UTF8? Or is that a hexadecimal representation of the source bytes? Could you briefly mention the code you used to get those hash values for both Dart and Python?
Sorry for the late response, not really keeping track on this project anymore.
Apparently the source text is an ASCII string to be converted to bytes as ASCII values, i.e. 0x31, 0x64, 0x33, 0x31, etc.
The following BC code produces the expected output:
var sourceText =
'1d31dc56a882c686e5355f367d2ea8393ef8535f19896e38c83f025062837e901d0400551802c5533661aabc96135de5eb91a982fdb9ba3a876043b8e883ae50';
var bytes = Uint8List.fromList(sourceText.codeUnits);
print(bytes.length);
print(SHA256Digest().process(bytes));
source text is '1d31dc56a882c686e5355f367d2ea8393ef8535f19896e38c83f025062837e901d0400551802c5533661aabc96135de5eb91a982fdb9ba3a876043b8e883ae50'
SHA256Digest.process returns: [209, 176, 92, 12, 94, 11, 223, 105, 236, 152, 90, 14, 40, 177, 184, 200, 217, 84, 250, 223, 10, 57, 94, 148, 101, 239, 149, 235, 193, 91, 136, 188]
Python hashlib sha256 returns:
[107, 25, 91, 95, 40, 19, 177, 140, 73, 50, 217, 152, 219, 191, 24, 89, 72, 242, 227, 38, 197, 232, 11, 4, 206, 241, 52, 249, 79, 92, 62, 171]