decryptTextFromFileSync method
Decrypts a plain text from srcFilePath file synchronously.
If BOM (Byte Order Mark) is present in decrypted data, interprets the data
in accordance with BOM. Otherwise the interpretation will depend on utf16
and endian arguments.
If the argument utf16 is set to true, decrypted data will be interpreted
as a list of UTF-16 bytes. Endianness depends on endian argument.
Otherwise the data will be interpreted as a list of UTF-8 bytes.
Returns String object containing decrypted text.
Implementation
String decryptTextFromFileSync(String srcFilePath,
{bool utf16 = false, Endian endian = Endian.big}) {
Uint8List decData = decryptDataFromFileSync(srcFilePath);
String srcString;
if ((decData[0] == 0xFE && decData[1] == 0xFF) ||
(decData[0] == 0xFF && decData[1] == 0xFE)) {
srcString = decData.toUtf16String();
} else if (decData[0] == 0xEF && decData[1] == 0xBB && decData[2] == 0xBF) {
srcString = decData.toUtf8String();
} else {
srcString =
utf16 ? decData.toUtf16String(endian) : decData.toUtf8String();
}
return srcString;
}