|
@@ -59,12 +59,17 @@ String intToHex(i) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// Converts an [int] or [BigInt] to a [Uint8List]
|
|
/// Converts an [int] or [BigInt] to a [Uint8List]
|
|
|
-Uint8List intToBuffer(i) {
|
|
|
|
|
|
|
+Uint8List intToBytes(i) {
|
|
|
return Uint8List.fromList(i == null || i == 0 || i == BigInt.zero ? [] : hex.decode(padToEven(intToHex(i).substring(2))));
|
|
return Uint8List.fromList(i == null || i == 0 || i == BigInt.zero ? [] : hex.decode(padToEven(intToHex(i).substring(2))));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-Uint8List stringToBuffer(String i) {
|
|
|
|
|
- return Uint8List.fromList(i.isEmpty ? [] : hex.decode(padToEven(stripHexPrefix(i))));
|
|
|
|
|
|
|
+Uint8List stringToBytes(String str) {
|
|
|
|
|
+ ArgumentError.checkNotNull(str);
|
|
|
|
|
+ if (str.isEmpty) {
|
|
|
|
|
+ return Uint8List(0);
|
|
|
|
|
+ }
|
|
|
|
|
+ // Use UTF-8 encoding to convert string to bytes
|
|
|
|
|
+ return Uint8List.fromList(utf8.encode(str));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// Get the binary size of a string
|
|
/// Get the binary size of a string
|