Tuesday, December 10, 2024

age.nvim

Neovim plugin for encrypting and decrypting text files inside neovim using age with ease.

Table of Contents

Installation

Install Age using your favorite plugin manager. For example, with lazy.nvim:

-- ~/.config/nvim/lua/plugins/age.lua

{
    'abhi-xyz/age.nvim',
    cmd = { "Age" },
    config = function()
      local key = require('key')

      require('age').setup({
        encrypt_and_del = true, -- will remove the original file after encrypting.
        public_key = "ageXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
        private_key = key.private_key, -- defined in another lua file which is not included in git for safety
      })
    end
}
-- ~/.config/nvim/lua/key.lua

return {
  private_key = "AGE-SECRET-KEY-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
}

Usage

Age provides the :Age command with the following syntax:

:Age [action]

Examples:

:Age genkey
:Age encrypt
:Age decrypt

What is age?

age is a simple, modern and secure file encryption tool.

It features small explicit keys, no config options, and UNIX-style composability.

Why Choose Age Over GPG?

  1. Simplicity: Age has a straightforward syntax and intuitive design, making it easier to use without extensive documentation.
  2. Modern Cryptography: Age uses state-of-the-art cryptographic algorithms like X25519, ChaCha20-Poly1305, and HMAC-SHA256, ensuring robust security.
  3. Minimal Attack Surface: Age's codebase is minimal and easier to audit compared to the complex and extensive GPG ecosystem.
  4. Portable Keys: Age uses compact, user-friendly key formats, which are easy to manage and transfer.
  5. Focused Use Case: Age is purpose-built for encrypting files securely and efficiently, without the additional complexity of key management and email encryption that GPG supports.