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

data-anonymizer

v0.1.0

Published

Anonymize sensitive data in a controlled, pseudo-random way

Downloads

13,047

Readme

Data anonymizer

Simple module for simple and predictable data anonymization.

Introduction

Sometimes, you want to provide realistic data to someone, but you don't want to give them your original data.

For example, you have a test server for your API, which talks to your test database. You don't want to have that database be a copy of your production database, because that would expose real names and real addresses of people.

What to do? You could replace all names by 'John Doe', but that would mean the test data is not representative of the real data anymore.

You can use this module to anonymize all sensitive strings in a predictable manner.

Synopsis

var DataAnonymizer = require('data-anonymizer');
var a = new DataAnonymizer({ seed: 'my secret seed' });

// Read your original data from somewhere.
var person = readPerson();

// Replace the sensitive fields.
person.firstName = a.anonymize(person.firstName);
person.lastName  = a.anonymize(person.lastName);

// Now you can store the data elsewhere.

Behaviour

Data anonymizer defines 5 character classes:

  • Uppercase letters (e.g. 'A')
  • Lowercase letters (e.g. 'f')
  • Numbers ('0' to '9')
  • Uppercase letters with diacritics (e.g. 'Å')
  • Lowercase letters with diacritics (e.g. 'ć')

Data anonymizer goes over each character in the input string. For each character, if it is in one of the defined character classes, it replaces the character by a character from the same class (sometimes replacing it by itself). If it's not in a defined character class, the character is left alone.

For a given seed, the behaviour on one specific system should always give the same results.

By default, diacritics are enabled. You can disabling them by doing var anonymizer = new Anonymizer({ diacritics: false }).

Seeding

It would be good if the same input string would be converted to the same output consistently. That way, if you run the anonymization process twice, maybe because your original data has a few extra fields, the result of the data that is anonymized again will be the same.

This can be accomplished with the seed constructor argument.

Configuration

// This seeds the anonymizer with your secret seed. This makes sure that the
// output becomes predictable for a given input.
var anonymizer = new Anonymizer({ seed: 'secret' });

// Disables diacritics. Any letters with diacritics are now left alone.
var anonymizer = new Anonymizer({ diacritics: false });

FAQ

Q. Can the original data be retrieved from the anonymized data without knowing the seed?

A. As I am not a cryptology expert, I do not know the answer to this question. If you want to be 100% sure that your original data cannot be retrieved, I recommend you find something else than this module. Something that is cryptologically sound.

Q. Why are you not using the British spelling for 'anonymisation'?

A. I would actually prefer to use the British spelling. Using the American spelling is a marketing decision, because I think more people will search for 'anonymization' than 'anonymisation'.