decodeThenDecrypt method
Implementation
Future<String> decodeThenDecrypt(String key, String base64nonce,
String base64mac, String base64Text, int payloadLength) async {
Scp.getInstance().log('Nonce: $base64nonce');
Scp.getInstance().log('base64mac: $base64mac');
Scp.getInstance().log('base64Text: $base64Text');
List<int> decodedKey = utf8.encode(key);
List<int> decodedNonce = base64.decode(base64nonce);
List<int> decodedText = base64.decode(base64Text);
List<int> decodedMac = base64.decode(base64mac);
Scp.getInstance().log('Text length: ${decodedText.length}');
Scp.getInstance().log('Text length: $payloadLength');
while (decodedText.length <= payloadLength) {
decodedText.add(0);
}
Scp.getInstance().log('Decoded combined: $decodedText');
return await decryptMessage(
decodedKey, decodedNonce, decodedMac, decodedText);
}