decodePayload function
Future<Map<String, dynamic> >
decodePayload(
- Uint8List bytes,
- SerializerStrategy serializer,
- CryptoStrategy? crypto,
- SecretKey? secretKey,
Shared decode: strip taint (0xAA), decrypt if marked (0xAE), deserialize.
Implementation
Future<Map<String, dynamic>> decodePayload(
Uint8List bytes,
SerializerStrategy serializer,
CryptoStrategy? crypto,
SecretKey? secretKey,
) async {
Uint8List decoded = bytes;
if (decoded.isNotEmpty && decoded[0] == 0xAA) {
decoded = decoded.sublist(1);
}
if (crypto != null && secretKey != null && decoded.isNotEmpty && decoded[0] == 0xAE) {
decoded = await crypto.decrypt(decoded.sublist(1), secretKey);
}
return serializer.deserialize(decoded);
}