From e6057b3c13f004477f4963f3cdf054e5ca1bf2f4 Mon Sep 17 00:00:00 2001 From: kongjun Date: Tue, 29 Apr 2025 04:05:35 +0000 Subject: feat: lock the encrypted file to read-only mode to avoid unintended corruption --- lua/encrypt/decrypt.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'lua/encrypt/decrypt.lua') diff --git a/lua/encrypt/decrypt.lua b/lua/encrypt/decrypt.lua index 2ae4e2a..72e93c3 100644 --- a/lua/encrypt/decrypt.lua +++ b/lua/encrypt/decrypt.lua @@ -20,6 +20,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) -- cgit v1.2.3 From c7a16c626a0379d9304e0337348affb4bde9ba4e Mon Sep 17 00:00:00 2001 From: kongjun Date: Tue, 6 May 2025 10:10:59 +0000 Subject: feat: support password with special characters --- lua/encrypt/decrypt.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lua/encrypt/decrypt.lua') diff --git a/lua/encrypt/decrypt.lua b/lua/encrypt/decrypt.lua index 72e93c3..de49019 100644 --- a/lua/encrypt/decrypt.lua +++ b/lua/encrypt/decrypt.lua @@ -5,7 +5,7 @@ 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 -- cgit v1.2.3 From a9e7d700eb546800e3d341bc53667964ac821a38 Mon Sep 17 00:00:00 2001 From: kongjun Date: Tue, 6 May 2025 10:14:39 +0000 Subject: feat: handle the case where the inputsecret() is cancelled --- lua/encrypt/decrypt.lua | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lua/encrypt/decrypt.lua') diff --git a/lua/encrypt/decrypt.lua b/lua/encrypt/decrypt.lua index de49019..a1d6b66 100644 --- a/lua/encrypt/decrypt.lua +++ b/lua/encrypt/decrypt.lua @@ -12,6 +12,10 @@ 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 -- cgit v1.2.3