hex function

String hex(
  1. List<int> bytes
)

Utility to encode a blob to allow blob query using 'hex(blob_field) = ?', Sqlite.hex([1,2,3])

Implementation

String hex(List<int> bytes) {
  final buffer = StringBuffer();
  for (var part in bytes) {
    if (part & 0xff != part) {
      throw FormatException('$part is not a byte integer');
    }
    buffer.write('${part < 16 ? '0' : ''}${part.toRadixString(16)}');
  }
  return buffer.toString().toUpperCase();
}