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]
  • [action] can be one of:
    • encrypt,
    • decrypt,
    • genkey

Examples:

  • Generates an age key pair into key.txt in current working directory.
:Age genkey
  • Kills the current buffer and switches to a previous buffer or creates a scratch buffer in case there is no buffer to switch, then encrypts the file with the provided age key.
:Age encrypt
  • Decrypts the currently opened encrypted file, and switches to the decrypted file.
: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.


This site is built with the Yew framework. The website’s source code is licensed under the MIT License and is available here. Articles are licensed under Creative Commons with the Share-alike Clause (CC-BY-SA 4.0).