decryptAppSecret static method
Implementation
static String decryptAppSecret({required String appId, required String aps}) {
// 1. Base64 decode both the app_id (key) and aps (the encrypted data)
final keyBytes = base64Decode(appId); // 32 bytes key
final rawEncryptedBytes = base64Decode(aps);
// 2. Split into IV and encrypted message
final ivBytes = rawEncryptedBytes.sublist(0, 16); // first 16 bytes
final encryptedMessageBytes = rawEncryptedBytes.sublist(16); // the rest
// 3. Create AES encrypter
final key = Key(keyBytes); // 256 bits = 32 bytes
final iv = IV(ivBytes);
final encrypter = Encrypter(AES(key, mode: AESMode.ctr, padding: null));
// 4. Decrypt the message
final decrypted = encrypter.decrypt(
Encrypted(encryptedMessageBytes),
iv: iv,
);
return decrypted; // The plain text app-secret
}