matchSymmetricKeys static method
Verifies that symmetric keys (encrypt/decrypt) are a matching pair.
Tests if the encryption key can encrypt the PROMISE data, and the decryption key can successfully decrypt it back to the original data.
@param encKey - Encryption key to test
@param decKey - Decryption key to test
@return True if keys are a valid matching pair, false otherwise
Implementation
static bool matchSymmetricKeys(EncryptKey encKey, DecryptKey decKey) {
// check by encryption
final params = <String, dynamic>{}.asMutableMapping();
Uint8List ciphertext = encKey.encrypt(PROMISE, params);
Uint8List? plaintext = decKey.decrypt(ciphertext, params);
return plaintext != null && Arrays.equals(plaintext, PROMISE);
}