Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A lightweight utility to generate pseudo-unique hash-like strings from input using simple, deterministic encoding.

License

Notifications You must be signed in to change notification settings

cttricks/pseudocrypt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

6 Commits

Repository files navigation

PseudoCrypt

✨ A tiny utility to generate short, deterministic, pseudo-unique hashes β€” not for security, just for fun and function.

Years ago, while working on a PHP project, I stumbled upon a brilliant little gem called PseudoCrypt by KevBurnsJr. It gave me compact, reversible hashes for integer IDs β€” just what I needed for pretty URLs.

Fast-forward to today, while building a Node + Express app, I wanted that same functionality. Nostalgia kicked in β€” so I re-imagined the logic in JavaScript, packed it into a clean NPM module, and now, I'm sharing it with the world.

πŸ“¦ Installation

To install PseudoCrypt via npm and use it in your Node.js projects:

npm i @cttricks/pseudocrypt

If you're building a front-end application or prefer to load PseudoCrypt directly in the browser, you can include it from the jsdelivr cdn.

<script src="https://cdn.jsdelivr.net/gh/cttricks/pseudocrypt@v1.0.0/dist/pseudocrypt.min.js"></script>

βš™οΈ Usage

const { encode, decode } = require('@cttricks/pseudocrypt');
const shortId = encode(1320588); // HdMxQ
const original = decode(shortId); // 1320588

Tip

You can also customize the hash length

const hash = encode(123456, 7); 

πŸ“š API

encode(number, length = 5)

  • Converts a number into a short, base62-like string.
  • Length determines the padded size of the output hash.

decode(string)

  • Reverses the encoded string back to the original number.

🧠 Use Cases

  • URL shortening
  • Obfuscating numeric IDs
  • Pretty URLs
  • Generating lightweight client-side keys

Warning

This is not a cryptographic hash β€” it’s meant for short pseudo-unique strings, not for passwords or secure encoding.

This little library was built with a blend of nostalgia, practicality, and a sprinkle of fun. If it saved you a few lines of code or gave your project some cleaner URLs β€” I’m glad it helped ✨

Feel free to fork it, remix it, improve it, or just drop a ⭐ on GitHub if you found it useful. No formalities, no promises β€” just code made with good vibes.

β€”

Happy hashing! πŸš€ β€” Tanish Raj / @cttricks

About

A lightweight utility to generate pseudo-unique hash-like strings from input using simple, deterministic encoding.

Topics

Resources

License

Stars

Watchers

Forks

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /