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

emojicoding

v0.3.0

Published

A library for encoding numbers and strings into emoji (base 1024) and decoding them back again. Useful for visually comparing Bitcoin, Ethereum, Stacks and other blockchain / crypto wallet addresses.

Downloads

9

Readme

Emojicoding (Base 1024)

Emojicoding: Base 1024

WARNING: This library is not extensively tested, so please use at your own risk. Alternatively, feel free to help out by expanding on the test suite.

About

Emojicoding is a library for encoding data to and from emojibase - a base 1024 encoding (10 bits of entropy per character), where each character is displayed as a single emoji.

With emojicoding, one can express a string of base 16 characters as many fewer emoji (approximately 0.4x the number of hexadecimal characters).

This makes it easier to visually compare two values.

For example, one can take a traditional Bitcoin address (a special encoding of 26-35 alphanumeric characters, or 40 hexadecimal characters), and express it as 16 emoji.

Try visually comparing each encoding and you'll see how much simpler and quicker it is to verify the address with the emoji representation.

Getting Started

Step 1: Install with npm or Yarn

npm:

npm install emojicoding

Yarn:

yarn add emojicoding

Step 2: Import the library

Modern JavaScript (ES6+)

import emojicoding from 'emojicoding'

Node

const emojicoding = require('emojicoding')

Encoding

First, get the value you'd like to encode. Here we'll create a random sequence of bytes:

> let bufferValue = crypto.randomBytes(8); console.log(bufferValue)
<Buffer e0 9c 56 3a 56 1d e6 ae>

Then encode it with the buffer value:

> let emojiValue = emojicoding.encodeToEmoji(bufferValue); console.log(emojiValue)
[ '🔨', '🌵', '🦖', '🍮', '✊', '🍷', '🧰' ]

Or pass it in as a hex string:

> let hexValue = bufferValue.toString('hex'); console.log(hexValue)
'e09c563a561de6ae'
> let emojiValue = emojicoding.encodeToEmoji(hexValue); console.log(emojiValue)
[ '🔨', '🌵', '🦖', '🍮', '✊', '🍷', '🧰' ]

Decoding

First, get your emoji value:

> console.log(emojiValue)
[ '🔨', '🌵', '🦖', '🍮', '✊', '🍷', '🧰' ]

Then decode it to a buffer:

> let recoveredBuffer = emojicoding.decodeFromEmoji(emojiValue, 'buffer'); console.log(recoveredBuffer)
<Buffer e0 9c 56 3a 56 1d e6 ae>

Or decode it to a hex string:

> let recoveredHex = emojicoding.decodeFromEmoji(emojiValue, 'hex'); console.log(recoveredHex)
'e09c563a561de6ae'

Examples

Example 1: Bitcoin Addresses

> const bs58check = require('bs58check')
> let bitcoinAddress = '1PMycacnJaSqwwJqjawXBErnLsZ7RkXUAs'
> let bitcoinAddressHex = bs58check.decode(bitcoinAddress).toString('hex').replace(/^00/, '')
> console.log(bitcoinAddressHex)
f54a5851e9372b87810a8e60cdd2e7cfd80b6e31
> let emojiAddress = emojicoding.encodeToEmoji(bitcoinAddressHex)
> console.log(emojiAddress.join(' '))
📯 👨 🍓 🌝 🦸‍♀️ 🎗 🌕 🧖‍♂️ 🥪 🍏 🧯 🚖 🏫 🐛 🚐 🥩

Example 2: Ethereum Accounts

> let ethereumAccount = '0x02F024e0882B310c6734703AB9066EdD3a10C6e0'
> let trimmedAccount = ethereumAccount.replace(/^0x/, '').toLowerCase()
> let emojiAccount = emojicoding.encodeToEmoji(trimmedAccount).join(' ')
> console.log(emojiAccount)
🙂 🚀 🧶 👋 👲 🏗 🌋 🏠 🐿 🚿 🍜 🍾 🧯 🦠 😡 🏍

Example 3: Stacks Addresses

> const c32check = require('c32check')
> let stacksAddress = 'SP2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKNRV9EJ7'
> let decodedAddress = c32check.c32addressDecode(stacksAddress)
> console.log(decodedAddress)
[ 22, 'a46ff88886c2ef9762d970b4d2c63678835bd39d' ]
> let emojiAddress = emojicoding.encodeToEmoji(decodedAddress[1])
> console.log(emojiAddress.join(' '))
🤸‍♂️ 🚤 🌶 🖐 🚥 🛩 🌷 🚑 🐾 🖥 👮 🍔 🌗 🥵 🚇 🕳