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

@cartago-git/keyer

v1.1.6

Published

Secret encrypter for keys, api-keys and envs

Downloads

36

Readme

Keyer

This app is just a library to encrypt and decrypt texts and any other variables with a salt.

Secret encrypter for keys, api-keys, envs or others

To install

To install in project

npm install @cartago-git/keyer

or for global install

npm install --global @cartago-git/keyer

CLI

CLI Basic

Keyer Cli:

Usage: keyer [options] or [command]
    -v                                       output Keyer current version
    -er, encrypt-route <encrypt-route>       route from file to encrypt (default: ".env")
    -edr, encrypted-route <encrypted-route>  route from file when it will be encrypted (default: "keyer/encrypted.txt")
    -dr, decrypted-route <decrypted-route>   route from file when it will be decrypted (default: "keyer/decrypted.txt")
    -h, --help                               output Keyer help

    Commands:
    encrypt [options]                        encrypt command cli
    decrypt [options]                        decrypt command cli

Keyer encrypt:

Usage: keyer encrypt [options]

encrypt command cli

Options:
    -f, --file <file>      route where is the file for encrypting (default: ".env")
    -o, --output <output>  route where file encrypted will create (default: "keyer/encrypted.txt")
    -s, --salt <salt>      secret salt (required option)
    -h, --help             output Keyer help

Keyer decrypt:

Usage: keyer decrypt [options]

decrypt command cli

Options:
    -f, --file <file>      route file (default: "keyer/encrypted.txt")
    -o, --output <output>  route where file will decrypted (default: "keyer/decrypted.txt")
    -s, --salt <salt>      secret salt (required option)
    -co, --create-output   create file output (default: false)
    -h, --help             output Keyer help

Library

Básic Methods

import {encrypt, decrypt, encryptAny, decryptAny}
encrypt(props: {
	toEncrypt: string;
	secretSalt: string;
	showLog?: boolean;  // (default:true)
}) => string
encryptAny(props: {
	toEncrypt: any;
	secretSalt: string;
	showLog?: boolean;  // (default:true)
}) => string
decrypt(props: {
	toDecrypt: string;
	secretSalt: string;
	showLog?: boolean;  // (default:true)
}) => string
decryptAny<T = any>(props: {
	toDecrypt: string;
	secretSalt: string;
	showLog?: boolean;  // (default:true)
}) => T

Commands Methods

import {keyerCommand, encryptCommand, decryptCommand}
keyerCommand({
	encryptRoute: string;
	encryptedRoute: string;
	decryptedRoute: string;
}) => void
encryptCommand({
	file: string;
	output: string;
	salt: string;
}) => void
decryptCommand({
	file: string;
	output: string;
	salt: string;
    	createOutput?: boolean // (default:false)
}) => void

Usage basic methods

For Example:

import {encrypt, decrypt, encryptAny, decryptAny}

const salt = "This is just a secret salt that you must hide for others";
const apiKey = 'api_false_example_to_show'

// To get the encrypted Hash
const apiKeyHash = encrypt({
    toEncrypt: apiKey,
    secretSalt: salt
})

// to get decrypt the Hash
const apiKeyDecrypted = decrypt({
    toDecrypt: apiKeyHash,
    secretSalt: salt
})

// NOTE - Example - With an object or other var kind
const objectToEncrypt = {
    name: 'Joe',
    prename: 'Doe',
    age: 30
}

// To get the encrypted Hash
const objectHash = encryptAny({
    toEncrypt: objectToEncrypt,
    secretSalt: salt
})

// to get decrypt Hash
const objectDecrypted = decryptAny({
    toDecrypt: objectHash,
    secretSalt: salt
})

console.log({apiKeyHash, apiKeyDecrypted, objectHash, objectDecrypted})

Optional

Every function has a showLog prop in true, just put it to false if doesnt want the encrypt log

encrypt({
    toEncrypt: apiKey,
    secretSalt: salt,
    showLog: false
})

NOTES

Allowed types or instances to encrypt and decrypt

typeof

  • string
  • number
  • boolean
  • null
  • undefined
  • object - (except with props with disallowed types or instances)
  • array - (except if It has some disallowed type or instance)

instanceof

  • Object
  • Date
  • RegExp
  • Map
  • Set
  • Error

Disallowed special types or instances to encrypt and decrypt

  • Function
  • Symbol
  • Bigint
  • any other non-serializable object