npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

yaml-crypt

v0.7.8

Published

Encrypt and decrypt YAML documents

Downloads

56

Readme

yaml-crypt

Build Status Coverage status License

Command line utility to encrypt and decrypt YAML documents.

Installation

The package is available on the npm registry, so just run

$ yarn global add yaml-crypt
$ yaml-crypt -h

You can also install the package locally:

$ mkdir yaml-crypt && cd yaml-crypt
$ yarn init --yes
$ yarn add yaml-crypt
$ ./node_modules/.bin/yaml-crypt -h

You can also use the Docker image:

$ docker run --rm autoapply/yaml-crypt -h

Usage

First you will need to generate a key file. Currently, both Fernet and Branca encryption schemes are supported.

To generate a new random key, run

$ yaml-crypt --generate-key > my-key-file

To encrypt all values in a YAML file, run

$ yaml-crypt -k my-key-file my-file.yaml

This will encrypt the file contents and rename the file to my-file.yaml-crypt.

The operation will be performed based on the file extension, so to decrypt a file, just use

$ yaml-crypt -k my-key-file my-file.yaml-crypt

To specify an explicit operation, use -e or -d for encryption or decryption.

You can also encrypt only certain parts of a file. Given the following YAML file

apiVersion: v1
kind: Secret
data:
  username: user1
  password: secret123

you can use --path data to only encrypt the values user1 and secret123.

Kubernetes secrets are Base64 encoded, so you should also use the --base64 (or -B) option.

It is also possible to directly open encrypted files in an editor, decrypting them before opening and encrypting again when saving:

$ yaml-crypt -E my-file.yaml-crypt

When editing, you can add new encrypted data by specifying the yaml tag <!yaml-crypt>:

unencrypted:
  hello: world
encrypted:
  key1: !<!yaml-crypt/:0> secret-key-1
  # add the following line to add a new encrypted entry "key2" to the file,
  # which will be encrypted in the yaml-crypt file:
  key2: !<!yaml-crypt> secret123

Configuration

The yaml-crypt command looks in ~/.yaml-crypt for a file config.yaml or config.yml. Currently, only the keys property is supported. These keys will be used when no keys are given on the command line:

$ cat ~/.yaml-crypt/config.yaml
keys:
- key: my-raw-key-data
- key: !!binary my-base64-key-data
$ yaml-crypt my-file.yaml

All whitespaces at the beginning and end of keys will be removed when reading keys.

Related projects

  • https://github.com/mozilla/sops
  • https://github.com/huwtl/secure_yaml
  • https://github.com/StackExchange/blackbox
  • https://github.com/bitnami-labs/sealed-secrets

License

The yaml-crypt tool is licensed under the MIT License