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

monguscate

v1.1.0

Published

Obfuscate ObjectID as used by MongoDB.

Downloads

3

Readme

Monguscate

Simple tool for obsfucating ObjectID used by MongoDB. The name is a really lame contraction of mongo and obfuscate. :P

Use this utility to obfuscate ObjectID issued by MongoDB when you use them in your API. It's always a good idea not to expose anything to the outside world, and this helps you keep your IDs a bit more secure.

You can now pass in your own function for swapping and xor'ing. You have to bear in mind, though, that the swap function should be "symmetrical". Basically, this means that swap_func(swap_func(x)) === x. In a real project, you would send an obfuscated version of x, which is de-obfuscated by obfuscating that value again.

Internally, the obfuscating function works like this:

var obfuscated_value = xor_func(swap_func(xor_func(x)));

XOR is symmetrical implictly, as long as it's the same value you're xor'ing with.

In the end, the obfuscating function must be symmetrical:

obfuscate(obfuscate(x)) === x;

should evaluate to true.

Installation

npm install monguscate --save

Usage

Version >= 1.0.0

var Obfuscate = require('monguscate');

// You can create your own swap and xor methods (not mandatory)
var my_swap = function (x) {
  // swap x in some manner (must be symmetrical)
};
var my_xor = function (x) {
  // Perform xor on x in some manner
};

var O = new Obfuscate();
O.setXorCallback(my_xor);     // override the default xor method
O.setSwapCallback(my_swap);   // override the default swap method

var x = '54f457292f559f0761000003';   // This is what an ObjectID looks like as a String
var obfuscated_x = O.obfuscate(x);
console.log('ObjectID ', x, 'obfuscated ObjectID ', obfuscated_x);

Version <= 0.2.1

var obfuscate = require('monguscate').obfuscate;
var x = '54f457292f559f0761000003';   // This is what an ObjectID looks like as a String
var obfuscated_x = obfuscate(x);
console.log('ObjectID ', x, 'obfuscated ObjectID ', obfuscated_x);

Tests

npm test

Release History

  • 0.1.0 Initial release
  • 0.2.0 Swap function only allows swapping both halves, because it must be a symmetrical function
  • 1.0.0 Added functionality to add your own swap and xor methods
  • 1.0.1 Updated README.
  • 1.0.2 Updated README: fixed a bug in the example.