encryptFileSync method
Encrypts srcFilePath
file to destFilePath
file synchronously.
If the argument destFilePath
is not specified, encrypted file name is created
as a concatenation of srcFilePath
and '.aes' file extension.
If encrypted file exists, the behaviour depends on AesCryptOwMode.
Returns String object containing the path to encrypted file.
Implementation
String encryptFileSync(String srcFilePath, [String destFilePath = '']) {
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 encrypted file path are the same.');
}
return _Cryptor.init(_passBytes, _owMode, _userdata)
.encryptFileSync(srcFilePath, destFilePath);
}