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

concealer

v2.0.0

Published

A primary key encoding utility

Downloads

24

Readme

Concealer

A fast two-way encryption module to generate unique, random-appearing, non-sequential strings from integers. This is a great way to encode database primary keys before presenting them to the user.

Build Status Coverage Status Current Version

Development on Concealer is sponsored by Sparo Labs.

And to make the output more URL-friendly, the algorithm automatically tries to avoid generating output with common English curse words by reserving some letters (cfhistuCFHISTU) for use as separators.

Security Note: This module uses the SKIP32 algorithm, which is a 80-bit key, 32-bit block symmetric cipher based on Skipjack. This module is not intended to be cryptographically secure; it may be possible, with enough encoded results, to determine the key and salt used and break the encryption. Please do not use this module for anything that you must keep absolutely secure; this module is more useful for making URL-ready strings representing database primary keys that you would rather not directly expose to the end-user.

Install

$ npm install --save concealer

Usage

new Concealer(secretKey, salt, [minLength], [customAlphabet])

Creates a new Concealer object where:

  • secretKey - An array of bytes to use for the secret key. The method will use up to the first ten bytes in the array and will duplicate values provided if there are less. It is highly recommended to provide all ten bytes for the most secure encryption.
  • salt - A string to use for the salt for the encryption process.
  • minLength - An optional minimum integer length for the output. Depending on the size of the primary key, the encoded string could be longer than the given minimum.
  • customAlphabet - An optional string to define a custom alphabet for generating the encoded string. The string must contain all unique characters, no spaces, and be at least 16 characters long.
const Concealer = require('concealer');

// Do ***NOT*** use these keys and salts in a production system
const key = [ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10 ];
const salt = 'example salt';
const minLength = 8;

const concealer = new Concealer(key, salt, minLength);

concealer.encode(key)

Encrypts and encodes an integer key into an obfuscated string where:

  • key - A non-negative integer to encode.

Returns the resulting encoded string.

concealer.encode(1);
// 'ZBoM3XdG'

concealer.encode(2);
// 'ZlllPKa5'

concealer.encode(3);
// 'D4GqMMzA'

concealer.decode(key)

Decrypts encoded key string back to a number where:

  • key - The encoded key string.

Returns the decoded number or null if the key string cannot be decoded.

concealer.decode('ZlllPKa5');
// 2

concealer.decode('manipulated key string');
// null

License

This project is licensed under the MIT license. See the LICENSE file for more info.