encryptAesGcmWeb function
Encrypts the given plaintext
using AES-GCM in the web environment.
The encryption is performed using a JavaScript function encryptAesGcm
exposed in the loaded script. The masterKey
should be a valid 256-bit key string.
Returns a Base64-encoded cipher text as String.
Implementation
Future<String> encryptAesGcmWeb(String masterKey, String plaintext) async {
final jsFunction = js_util.getProperty(window, 'encryptAesGcm');
final promise = js_util.callMethod(jsFunction, 'call', [null, masterKey, plaintext]);
return await js_util.promiseToFuture(promise);
}