encryptTextToFile method

Future<String> encryptTextToFile(
  1. String srcString,
  2. String destFilePath, {
  3. bool utf16 = false,
  4. Endian endian = Endian.big,
  5. bool bom = false,
})

Encrypts a plain text string srcString to destFilePath file asynchronously.

By default the text string will be converted to a list of UTF-8 bytes before it is encrypted.

If the argument utf16 is set to true, the text string will be converted to a list of UTF-16 bytes. Endianness depends on endian argument.

If the argument bom is set to true, BOM (Byte Order Mark) is appended to the beginning of the string before it is encrypted.

Returns Future<String> that completes with the path to encrypted file once the entire operation has completed.

Implementation

Future<String> encryptTextToFile(String srcString, String destFilePath,
    {bool utf16 = false,
    Endian endian = Endian.big,
    bool bom = false}) async {
  Uint8List bytes = utf16
      ? srcString.toUtf16Bytes(endian, bom)
      : srcString.toUtf8Bytes(bom) as Uint8List;
  return await encryptDataToFile(bytes, destFilePath);
}