decryptAesGcmWeb function

Future<String> decryptAesGcmWeb(
  1. String masterKey,
  2. String cipherText
)

Decrypts the given cipherText using AES-GCM in the web environment.

The decryption is performed using a JavaScript function decryptAesGcm exposed in the loaded script. The masterKey must be the same key used during encryption.

Returns the original plain text as String.

Implementation

Future<String> decryptAesGcmWeb(String masterKey, String cipherText) async {
  final jsFunction = js_util.getProperty(window, 'decryptAesGcm');
  final promise = js_util.callMethod(jsFunction, 'call', [null, masterKey, cipherText]);
  return await js_util.promiseToFuture(promise);
}