encryptTextToFileSync method

String encryptTextToFileSync(
  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 synchronously.

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 text string before it is encrypted.

Returns String object containing the path to encrypted file.

Implementation

String encryptTextToFileSync(String srcString, String destFilePath,
    {bool utf16 = false, Endian endian = Endian.big, bool bom = false}) {
  Uint8List bytes = utf16
      ? srcString.toUtf16Bytes(endian, bom)
      : srcString.toUtf8Bytes(bom) as Uint8List;
  return encryptDataToFileSync(bytes, destFilePath);
}