base64UintEncode function
Encode unsigned BigInt value as base64url without padding.
Implementation
String base64UintEncode(BigInt number) {
final oneByte = BigInt.from(0xff);
if (number.isNegative) {
throw ApiError('Negative BigInt cannot be encoded to base64uint.');
}
var temp = number;
final bytes = <int>[];
while (temp > BigInt.zero) {
bytes.insert(0, (temp & oneByte).toInt());
temp >>= 8;
}
return stripBase64Padding(base64UrlEncode(bytes));
}