hexToUint8List function
Convert hex to binary data */
Implementation
Uint8List hexToUint8List(String hex) {
if (!(hex is String)) {
throw 'Expected string containing hex digits';
}
if (hex.length % 2 != 0) {
throw 'Odd number of hex digits';
}
var l = hex.length ~/ 2;
var result = new Uint8List(l);
for (var i = 0; i < l; ++i) {
var x = int.parse(hex.substring(i * 2, (2 * (i + 1))), radix: 16);
if (x.isNaN) {
throw 'Expected hex string';
}
result[i] = x;
}
return result;
}