decryptSerializedStringWithKey method

Future<Uint8List> decryptSerializedStringWithKey(
  1. String serialized,
  2. EncryptionKey key
)
inherited

Implementation

Future<Uint8List> decryptSerializedStringWithKey(
    String serialized, EncryptionKey key) async {
  assert(key is KeyPair, 'RSA decryption requires a `KeyPair`');
  final KeyPair keyPair = key as KeyPair;
  assert(
      keyPair.privateKey != null, 'Private key is required for decryption');

  final items = serialized.split('.');
  final decodedPairs = items.sublist(1);
  final encryptedBytes = base64Url.decode(decodedPairs[0]);
  return _decryptWithPrivateKey(keyPair.privateKey!, encryptedBytes);
}