// Display helpers for the keys and ids the native library hands back as // base32 and hex — formatting only, no protocol meaning. import "dart:typed_data"; /// Lowercase hex, as the message ids cross the ABI. String hex(List bytes) => bytes.map((b) => b.toRadixString(16).padLeft(2, "0")).join(); /// The compact human check for a key: the first 20 base32 characters in /// groups of four, the same shape every smol client shows. String fingerprint(String keyB32) { final s = keyB32.substring(0, 20); return RegExp(".{4}").allMatches(s).map((m) => m[0]).join(" "); } /// The inverse of [hex]; throws on anything that is not even-length hex. Uint8List unhex(String text) { if (text.length % 2 != 0) { throw FormatException("odd-length hex string"); } return Uint8List.fromList( [for (var i = 0; i < text.length; i += 2) int.parse(text.substring(i, i + 2), radix: 16)]); }