decryptString method

Future<String> decryptString(
  1. SecretBox secretBox, {
  2. required SecretKey secretKey,
})

Calls decrypt and then converts the bytes to a string by using utf8 codec.

Implementation

Future<String> decryptString(
  SecretBox secretBox, {
  required SecretKey secretKey,
}) async {
  final clearText = await decrypt(
    secretBox,
    secretKey: secretKey,
  );
  try {
    return utf8.decode(clearText);
  } finally {
    // Don't leave possibly sensitive data in the heap.
    clearText.fillRange(0, clearText.length, 0);
  }
}