decryptFile method
Decrypts srcFilePath
file to destFilePath
file asynchronously.
If the argument destFilePath
is not specified, decrypted file name is created
by removing '.aes' file extension from srcFilePath
.
If it has no '.aes' extension, then decrypted file name is created by adding
'.decrypted' file extension to srcFilePath
.
If decrypted file exists, the behaviour depends on AesCryptOwMode.
Returns Future<String> that completes with the path to decrypted file once the entire operation has completed.
Implementation
Future<String> decryptFile(String srcFilePath,
[String destFilePath = '']) async {
srcFilePath = srcFilePath.trim();
destFilePath = destFilePath.trim();
AesCryptArgumentError.checkNullOrEmpty(_password, 'Empty password.');
AesCryptArgumentError.checkNullOrEmpty(
srcFilePath, 'Empty source file path.');
if (srcFilePath == destFilePath) {
throw AesCryptArgumentError(
'Source file path and decrypted file path are the same.');
}
return await _Cryptor.init(_passBytes, _owMode, _userdata)
.decryptFile(srcFilePath, destFilePath);
}