decryptFileSync method

String decryptFileSync(
  1. String srcFilePath, [
  2. String destFilePath = ''
])

Decrypts srcFilePath file to destFilePath file synchronously.

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 String object containing the path to decrypted file.

Implementation

String decryptFileSync(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 decrypted file path are the same.');
  }
  return _Cryptor.init(_passBytes, _owMode, _userdata)
      .decryptFileSync(srcFilePath, destFilePath);
}