aboutsummaryrefslogtreecommitdiff
path: root/lua/encrypt/decrypt.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/encrypt/decrypt.lua')
-rw-r--r--lua/encrypt/decrypt.lua7
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)