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

@mcbe-mods/crypto

v1.0.0-beta.6

Published

Symmetric encryption for MCBE Script API — XChaCha20-Poly1305 with password/key support

Readme

@mcbe-mods/crypto

npm version npm downloads License

Symmetric encryption for Minecraft Bedrock Edition Script API — XChaCha20-Poly1305 with password/key support.

Designed to pair with @mcbe-mods/protocol for encrypted in-world communication.

Install

npm install @mcbe-mods/crypto

Usage

From password

import { Cipher } from '@mcbe-mods/crypto'
import { Protocol } from '@mcbe-mods/protocol'

const cipher = Cipher.fromPassword('my-shared-secret')
const protocol = new Protocol({ cipher })

protocol.post('bedrock://my-addon/info', 'hello') // automatically encrypted
protocol.on((event) => {
  event.message // automatically decrypted
})

The optional second argument salt lets you scope a password to a specific project. When omitted, it defaults to a salt bound to this monorepo (github.com/mcbe-mods/runtime):

// Default salt (github.com/mcbe-mods/runtime)
Cipher.fromPassword('secret')
// Custom string salt
Cipher.fromPassword('secret', 'my-project-id')
// Custom binary salt
Cipher.fromPassword('secret', new Uint8Array([1, 2, 3, 4]))

Security note: the default salt is tied to this monorepo to prevent accidental key reuse across projects. In production, pass an app-specific salt or manage keys directly via fromKey. Both sides must use the same password + salt combination.

From raw key

const key = new Uint8Array(32).fill(42)
const cipher = Cipher.fromKey(key)

Both sides must use the same password or key for communication to work.

Custom random source

By default, nonces are generated using Math.random(), which is safe for XChaCha20-Poly1305's 192-bit nonce space but not cryptographically secure. You can inject any random bytes function via CipherOptions:

const cipher = Cipher.fromPassword('secret', undefined, {
  randomBytes(size) {
    // Use any available random source
    const buf = new Uint8Array(size)
    for (let i = 0; i < size; i++) {
      buf[i] = (Math.random() * 256) | 0
    }
    return buf
  },
})

This works with both fromPassword and fromKey.

Note: @minecraft/server does not provide a secure random API. If your runtime has access to one (e.g. Web crypto.getRandomValues), you can pass it here.

License

MIT