颤振文件选择器复制相同的文件

时间:2021-07-15 20:51:03

标签: flutter dart encryption filepicker

当我选择文件以使用 AES 加密对其进行加密时 加密文件和原始文件复制到加密目录

我只想存储以 fileName.aes 结尾的加密文件

这是我的代码:

 Directory d = await getExternalVisibleDir;
                FilePickerResult result = await FilePicker.platform.pickFiles();
                File file = File(result.files.single.path);

                try {
                    final File newFile = await file.copy('${d.path}/${file.path.split('/').last}');
                    encFilepath = crypt.encryptFileSync(newFile.path);
                    print('The encryption has been completed successfully.');
                    print('Encrypted file: $encFilepath');
                } on AesCryptException catch (e) {
                  if (e.type == AesCryptExceptionType.destFileExists) {
                    print('The encryption has been completed unsuccessfully.');
                    print("message : ${e.message}");
                  }
                  return;
                }

0 个答案:

没有答案