salsa20Encrypt method

Future<String> salsa20Encrypt(
  1. String secretKey,
  2. String value
)

Encrypts value using Salsa20 encryption with the provided secretKey.

secretKey is the key used for encryption. value is the data to be encrypted. Returns the encrypted value as a Base64 string.

Implementation

Future<String> salsa20Encrypt(String secretKey, String value) async {
  final key = Key.fromLength(32);
  final iv = IV.fromLength(8);
  final encrypter = Encrypter(Salsa20(key));
  final encrypted = encrypter.encrypt(value, iv: iv);

  await SharedPreferencesWrapper.addMap(
      EncryptionConstants.encryptionMapKey, {accessKey: secretKey});

  return encrypted.base64;
}