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

crypto-pi

v0.0.6

Published

crypto-pi is an npm module that provides a novel text encryption and decryption method by mapping character codes to their positions within the digits of π (pi). Encrypt your text with π-based indexing and decrypt it back to its original form. A fun and c

Downloads

10

Readme

crypto-pi

npm version

crypto-pi is an npm module that provides text encryption and decryption based on the positions of character codes within the mathematical constant π (pi). It uses the char codes index inside the π number to crypt the text and then can be decrypted back to its original form.

Installation

To use crypto-pi in your Node.js project, you can install it using npm:

npm install crypto-pi

Usage

Import the module and use the provided functions to encrypt and decrypt your text.

import { encrypt, decrypt } from "crypto-pi";

(async () => {
	const text = "Hello, world!";
	const encryptedText = await encrypt(text);
	console.log("Encrypted:", encryptedText);

	let result = await decrypt(encryptedText); // This will log "Hello, world!" to the console
	console.log(result);
})();

How it works

The module knows the first million chars of π (pi) from a local file called pi.txt, which should contain the digits of π (pi). The functions encrypt and decrypt use this information to perform the encryption and decryption processes.

Encryption process

  1. For each character in the input text, the module finds the index of its char code within the π (pi) digits.
  2. It concatenates the found indexes into a single string, separating each index with a dot (.).
  3. It also appends two more dot-separated strings to the result string. The first string contains the length of each char code, and the second string contains the length of each index string.

Decryption process

  1. The decryption process begins by splitting the input string into three parts using the dots (.) as separators.
  2. The first part contains the concatenated indexes of the char codes within the π (pi) digits.
  3. The second part contains the length of each char code in the original text.
  4. The third part contains the length of each index in the first part.
  5. The module then iterates over the lengths in the second part to extract each char code index and its length from the first part.
  6. It looks up the corresponding char code from the π (pi) digits using the extracted index and length.
  7. The decrypted char codes are then converted back to characters, resulting in the original text.

Limitations

Please note that this encryption method is not intended for strong security purposes. It is primarily a fun and creative approach to encrypting text based on the position of character codes in the π (pi) number.

Contributing

Contributions to the crypto-pi module are welcome! If you find any issues or want to add new features, please feel free to create a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.