diff options
author | Saturneric <[email protected]> | 2022-01-04 16:03:18 +0000 |
---|---|---|
committer | Saturneric <[email protected]> | 2022-01-04 16:03:18 +0000 |
commit | c2f05ec557ec53f62872e19cc463257481421e4f (patch) | |
tree | 9fd060663bca9f34cf3126e2a4c7cd4728159e9b /src/gpg/function/GpgFileOpera.cpp | |
parent | <fix, refactor>(core, ui): fixed known bugs for v2.0.4-beta.1. (diff) | |
download | GpgFrontend-c2f05ec557ec53f62872e19cc463257481421e4f.tar.gz GpgFrontend-c2f05ec557ec53f62872e19cc463257481421e4f.zip |
<feature, fix>(core, ui): support file symmetric encryption.
1. improve ui for file & text symmetric encryption.
Diffstat (limited to '')
-rw-r--r-- | src/gpg/function/GpgFileOpera.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/gpg/function/GpgFileOpera.cpp b/src/gpg/function/GpgFileOpera.cpp index b5c907a2..8babfa6d 100644 --- a/src/gpg/function/GpgFileOpera.cpp +++ b/src/gpg/function/GpgFileOpera.cpp @@ -134,3 +134,19 @@ gpg_error_t GpgFrontend::GpgFileOpera::DecryptVerifyFile( return err; } +unsigned int GpgFrontend::GpgFileOpera::EncryptFileSymmetric( + const std::string& in_path, const std::string& out_path, + GpgFrontend::GpgEncrResult& result, int _channel) { + std::string in_buffer = read_all_data_in_file(in_path); + std::unique_ptr<std::string> out_buffer; + + auto err = BasicOperator::GetInstance(_channel).EncryptSymmetric( + in_buffer, out_buffer, result); + + if (check_gpg_error_2_err_code(err) == GPG_ERR_NO_ERROR) + if (!write_buffer_to_file(out_path, *out_buffer)) { + throw std::runtime_error("write_buffer_to_file error"); + }; + + return err; +} |