fix: read back sent copies after the sec 5.6 upstream fix, pinned at 2d65d66
This commit is contained in:
parent
52947e153d
commit
d6f4c434fa
36 changed files with 4223 additions and 3118 deletions
24
lib/smol/ui.dart
Normal file
24
lib/smol/ui.dart
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
// 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<int> 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)]);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue