diff options
| author | David Elentok <3david@gmail.com> | 2025-05-06 22:04:23 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-06 22:04:23 +0300 |
| commit | 363e1d924c6235ae4e9170b1e2ebab50a2e26c07 (patch) | |
| tree | bf21093fa70c8ed8014e70f4841714d622ec651e /lua/encrypt/decrypt.lua | |
| parent | 09d7f6ee9ee1d728449131dff4e750e5339f7968 (diff) | |
| parent | a9e7d700eb546800e3d341bc53667964ac821a38 (diff) | |
| download | encrypt.nvim-363e1d924c6235ae4e9170b1e2ebab50a2e26c07.tar.gz | |
Merge pull request #2 from kongjun18/main
Some Improvement
Diffstat (limited to 'lua/encrypt/decrypt.lua')
| -rw-r--r-- | lua/encrypt/decrypt.lua | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lua/encrypt/decrypt.lua b/lua/encrypt/decrypt.lua index 2ae4e2a..a1d6b66 100644 --- a/lua/encrypt/decrypt.lua +++ b/lua/encrypt/decrypt.lua @@ -5,13 +5,17 @@ local helpers = require("encrypt.helpers") ---@param password string local function decrypt_lines(lines, password) return vim.fn.systemlist( - "base64 --decode | openssl enc -d -aes-256-cbc -pbkdf2 -salt -in - -out - -k " .. password, + "base64 --decode | openssl enc -d -aes-256-cbc -pbkdf2 -salt -in - -out - -k " .. vim.fn.shellescape(password), lines ) end local function decrypt() local password = helpers.getPassword() + if not password then + vim.notify("Password can not be empty", vim.log.levels.ERROR) + return + end local encrypted_lines = vim.api.nvim_buf_get_lines(0, 1, -1, false) local decrypted_lines = decrypt_lines(encrypted_lines, password) if vim.v.shell_error ~= 0 then @@ -20,6 +24,7 @@ local function decrypt() end vim.fn.timer_start(0, function() + vim.bo.modifiable = true vim.api.nvim_buf_set_lines(0, 0, -1, false, decrypted_lines) vim.bo.modified = false end) |
