Add decrypt support

This commit is contained in:
Jonas Hahn
2026-01-08 00:12:56 +01:00
parent 58fccf8739
commit 3fcf06a802

View File

@@ -29,25 +29,30 @@ return {
return info("No file selected") return info("No file selected")
end end
if hovered:match("%.gpg$") then
return info("This file is already encrypted")
end
if not default_recipient then if not default_recipient then
return info("No recipient set") return info("No recipient set")
end end
if hovered:match("%.gpg$") then
local plain_hovered = hovered:gsub("%.gpg$", "")
local _, err = Command("gpg"):arg("--yes"):arg("--recipient"):arg(default_recipient):arg("--output"):arg(plain_hovered):arg("--decrypt"):arg(hovered):output()
if err then
return info("Failed to gpg with error: " .. err)
end
else
local _, err = Command("gpg"):arg("--yes"):arg("--recipient"):arg(default_recipient):arg("--output"):arg(hovered .. local _, err = Command("gpg"):arg("--yes"):arg("--recipient"):arg(default_recipient):arg("--output"):arg(hovered ..
".gpg"):arg("--encrypt"):arg(hovered):output() ".gpg"):arg("--encrypt"):arg(hovered):output()
if err then if err then
return info("Failed to gpg with error: " .. err) return info("Failed to gpg with error: " .. err)
end end
end
-- Delete the plain file -- Delete the plain file
if delete_after == true then if delete_after == true then
os.remove(hovered) os.remove(hovered)
end end
info("Done encrypting the file! The plain one is deleted now.") info("Done encrypting/decrypting the file! The plain one is deleted now.")
end, end,
} }