toHex static method

String toHex(
  1. List<int> bytes
)

Converts a byte array to a hexadecimal string.

@param bytes a byte array @return a string of hexadecimal digits

Implementation

static String toHex(List<int> bytes) {
  if (!(bytes is Uint8List)) {
    bytes = Uint8List.fromList(bytes);
  }
  return HEX.encode(bytes);
//    StringBuffer buf = new StringBuffer();
//    for (int i = 0; i < bytes.length; i++) {
//      int b = bytes[i];
//      buf.write(toHexDigit((b >> 4) & 0x0F));
//      buf.write(toHexDigit(b & 0x0F));
//    }
//    return buf.toString();
//  }
//
//
//  static String toHexDigit(int n) {
//    if (n < 0 || n > 15) throw new ArgumentError("Nibble value out of range: $n");
//    if (n <= 9) return '0$n';
//    return 'A${n - 10}';
}