Fixes a invalid length hash due to the way dart outputs hex

This commit is contained in:
zontreck 2024-05-16 02:59:10 -07:00
parent b2f12eae15
commit 9348bf1370
2 changed files with 11 additions and 3 deletions

View file

@ -7,7 +7,7 @@ class Hashing {
var hash = md5.convert(utf8.encode(input)).bytes;
String x = "";
for (int byte in hash) {
x += byte.toRadixString(16);
x += byte.toRadixString(16).padLeft(2, '0');
}
return x;
@ -17,7 +17,7 @@ class Hashing {
var hash = sha1.convert(utf8.encode(input)).bytes;
String x = "";
for (int byte in hash) {
x += byte.toRadixString(16);
x += byte.toRadixString(16).padLeft(2, '0');
}
return x;
@ -27,7 +27,7 @@ class Hashing {
var hash = sha256.convert(utf8.encode(input)).bytes;
String x = "";
for (int byte in hash) {
x += byte.toRadixString(16);
x += byte.toRadixString(16).padLeft(2, '0');
}
return x;