4

Currently flutter web encryption/decryption fails due to unimplemented datatype. "Unsupported operation: Uint64 accessor not supported by dart2js."

I want to run the following code from the encrypt flutter package in my flutter web app.

import 'package:encrypt/encrypt.dart';

void main() {
  final plainText = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit';
  final key = Key.fromUtf8('my 32 length key................');
  final iv = IV.fromLength(16);

  final encrypter = Encrypter(AES(key));

  final encrypted = encrypter.encrypt(plainText, iv: iv);
  final decrypted = encrypter.decrypt(encrypted, iv: iv);

  print(decrypted); // Lorem ipsum dolor sit amet, consectetur adipiscing elit
  print(encrypted.base64); // R4PxiU3h8YoIRqVowBXm36ZcCeNeZ4s1OvVBTfFlZRdmohQqOpPQqD1YecJeZMAop/hZ4OxqgC1WtwvX/hP9mw==
}

When running the app on the browser the code will fail due to an unimplemented data type. error: "Unsupported operation: Uint64 accessor not supported by dart2js." This is a well-known issue and it does not appear there are plans to implement these datatypes.

The fernet specification requires a 64bit timestamp as part of its token.

I'm hoping to find a suitable alternative to perform symmetric key encryption on a flutter web app.

jockerThe00
  • 136
  • 1
  • 5

0 Answers0