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 🙏

© 2026 – Pkg Stats / Ryan Hefner

magiccrypt

v6.0.0

Published

MagicCrypt is a Java/PHP/NodeJS/Rust library to encrypt/decrypt strings, files, or data, using Data Encryption Standard(DES) or Advanced Encryption Standard(AES) algorithms. It supports CBC block cipher mode, PKCS7 padding and 64, 128, 192 or 256-bits key

Readme

MagicCrypt

CI

MagicCrypt is a Java/PHP/NodeJS/Rust library to encrypt/decrypt strings, files, or data, using Data Encryption Standard(DES) or Advanced Encryption Standard(AES) algorithms. It supports CBC block cipher mode, PKCS7 padding and 64, 128, 192 or 256-bits key length. If the encrypted data is a string, it will be formatted automatically to Base64.

Security Notice

MagicCrypt uses an older encryption design and is not recommended for new projects.

For new applications, please use a modern library that supports authenticated encryption. Authenticated encryption can protect encrypted data from both reading and unauthorized changes.

Requirements and Installation

Node.js 24 or later and Rust 1.89 or later are required. Install Rust with rustup and the native linker for your platform (a C compiler on Linux/macOS or the MSVC build tools on Windows).

npm install magiccrypt

Installation compiles the native module from source using the included Cargo.lock. There are no prebuilt platform packages. Package managers that block dependency build scripts must allow the magiccrypt install script; for pnpm, approve magiccrypt with pnpm approve-builds and rebuild it with pnpm rebuild magiccrypt. If npm requires script approval, use npm install-scripts approve magiccrypt followed by npm rebuild magiccrypt.

For Node.js

Encrypt

You can use encrypt method to encrypt any string. For example,

import { MagicCrypt } from "magiccrypt";

const mc = new MagicCrypt("magickey", 256);
console.log(mc.encrypt("http://magiclen.org"));

The result is,

DS/2U8royDnJDiNY2ps3f6ZoTbpZo8ZtUGYLGEjwLDQ=

To encrypt any data to a base64 string, pass a Buffer or a Uint8Array,

import { Buffer } from "node:buffer";

import { MagicCrypt } from "magiccrypt";

const mc = new MagicCrypt("magickey", 256);
const data = Buffer.from("http://magiclen.org", "utf8");
console.log(mc.encryptData(data));

Decrypt

You can use decrypt method to decrypt any encrypted string. For example,

import { MagicCrypt } from "magiccrypt";

const mc = new MagicCrypt("magickey", 256);
console.log(mc.decrypt("DS/2U8royDnJDiNY2ps3f6ZoTbpZo8ZtUGYLGEjwLDQ="));

The result is,

http://magiclen.org

To decrypt a base64 string to a data buffer,

import { MagicCrypt } from "magiccrypt";

const mc = new MagicCrypt("magickey", 256);
const buffer = mc.decryptData("DS/2U8royDnJDiNY2ps3f6ZoTbpZo8ZtUGYLGEjwLDQ=");

A base64 string that is not well-formed, or a ciphertext that was not produced by the same key and IV, throws an error.

Key Size and IV

The second argument of the constructor is the key size in bits: 64 uses DES, while 128, 192 and 256 use AES. It defaults to 128. The key itself may be any length, as it is hashed to the size the cipher needs.

The third argument is the initialization vector (IV). It is optional and defaults to an empty string, which means an all-zero IV.

import { MagicCrypt } from "magiccrypt";

const mc = new MagicCrypt("magickey", 256, "123456789");
console.log(mc.encrypt("https://magiclen.org"));

The result is,

ixCZtfFVt01DgOX+WmsqERcd1efq/yVpGLc5SfTVYXc=

For Java

Refer to https://github.com/magiclen/MagicCrypt.

For PHP

Refer to https://github.com/magiclen/MagicCrypt.

For Rust

Refer to https://github.com/magiclen/rust-magiccrypt.

License

MIT