encryptSymmetricString function

String encryptSymmetricString(
  1. String message,
  2. String passphrase
)

Encrypts the given string using NaCl SecretBox and returns a Base64 string containing nonce[24] + cipherText[]. The 24 first bytes must contain the nonce, and the rest of the buffer needs to contain the cipher text.

Implementation

String encryptSymmetricString(String message, String passphrase) {
  final messageBytes = Uint8List.fromList(utf8.encode(message));
  final encryptedBuffer = encryptSymmetricRaw(messageBytes, passphrase);

  return base64.encode(encryptedBuffer);
}