Code Monkey home page Code Monkey logo

ecoji-1's Introduction

Ecoji ๐Ÿฃ๐Ÿ”‰๐Ÿฆ๐Ÿ”ผ

Ecoji encodes data as 1024 emojis. It's base1024 with an emoji character set. As a bonus, this repo includes code to decode emojis to the original data they represent.

Many have asked how Ecoji compares to base64. The short answer is that a string encoded with Ecoji will have more bytes, but fewer visible characters, than the same string encoded with base64. With Ecoji, each visible char represents 10 bits, but each character is multi-byte. With base64 each char represents 6 bits and is one byte. The following table shows encoding sha256 in different ways.

Encoding Bytes Characters
none 32 N/A
hex 64 64
base64 44 44
ecoji 112 28

Installing

Ecoji is published on snapcraft.io and can be installed with :

sudo snap install ecoji

Usage

$ ecoji -h
usage: ecoji [OPTIONS]... [FILE]

Encode or decode data as Unicode emojis. ๐Ÿ˜

Options:
    -d, --decode          decode data
    -w, --wrap=COLS       wrap encoded lines after COLS character (default 76).
                          Use 0 to disable line wrapping
    -h, --help            Print this message
    -v, --version         Print version information.

Examples

Encoding:

$ echo "Base64 is so 1999, isn't there something better?" | ecoji
๐Ÿ—๐Ÿ“ฉ๐ŸŽฆ๐Ÿ‡๐ŸŽ›๐Ÿ“˜๐Ÿ”ฏ๐Ÿšœ๐Ÿ’ž๐Ÿ˜ฝ๐Ÿ†–๐ŸŠ๐ŸŽฑ๐Ÿฅ๐Ÿš„๐ŸŒฑ๐Ÿ’ž๐Ÿ˜ญ๐Ÿ’ฎ๐Ÿ‡ต๐Ÿ’ข๐Ÿ•ฅ๐Ÿญ๐Ÿ”ธ๐Ÿ‰๐Ÿšฒ๐Ÿฆ‘๐Ÿถ๐Ÿ’ข๐Ÿ•ฅ๐Ÿ”ฎ๐Ÿ”บ๐Ÿ‰๐Ÿ“ธ๐Ÿฎ๐ŸŒผ๐Ÿ‘ฆ๐ŸšŸ๐Ÿฅด๐Ÿ“‘

Decoding:

$ echo ๐Ÿ—๐Ÿ“ฉ๐ŸŽฆ๐Ÿ‡๐ŸŽ›๐Ÿ“˜๐Ÿ”ฏ๐Ÿšœ๐Ÿ’ž๐Ÿ˜ฝ๐Ÿ†–๐ŸŠ๐ŸŽฑ๐Ÿฅ๐Ÿš„๐ŸŒฑ๐Ÿ’ž๐Ÿ˜ญ๐Ÿ’ฎ๐Ÿ‡ต๐Ÿ’ข๐Ÿ•ฅ๐Ÿญ๐Ÿ”ธ๐Ÿ‰๐Ÿšฒ๐Ÿฆ‘๐Ÿถ๐Ÿ’ข๐Ÿ•ฅ๐Ÿ”ฎ๐Ÿ”บ๐Ÿ‰๐Ÿ“ธ๐Ÿฎ๐ŸŒผ๐Ÿ‘ฆ๐ŸšŸ๐Ÿฅด๐Ÿ“‘ | ecoji -d
Base64 is so 1999, isn't there something better?

Concatenation:

$ echo -n abc | ecoji
๐Ÿ‘–๐Ÿ“ธ๐ŸŽˆโ˜•
$ echo -n 6789 | ecoji
๐ŸŽฅ๐Ÿค ๐Ÿ“ ๐Ÿ
$ echo XY | ecoji
๐Ÿฒ๐Ÿ‘ก๐Ÿ•Ÿโ˜•
$ echo ๐Ÿ‘–๐Ÿ“ธ๐ŸŽˆโ˜•๐ŸŽฅ๐Ÿค ๐Ÿ“ ๐Ÿ๐Ÿฒ๐Ÿ‘ก๐Ÿ•Ÿโ˜• | ecoji -d
abc6789XY

Making Hashes More Interesting

$ cat encode.go  | openssl dgst -binary -sha1 | ecoji
๐ŸŒฐ๐Ÿ๐Ÿก๐ŸšŸ๐Ÿ”ถ๐Ÿฆ…๐Ÿ˜ก๐Ÿ˜บ๐Ÿš†๐Ÿ‘๐Ÿ•ก๐Ÿฆž๐Ÿ“๐Ÿ–Š๐Ÿ™€๐Ÿฆ‰
$ echo ๐ŸŒฐ๐Ÿ๐Ÿก๐ŸšŸ๐Ÿ”ถ๐Ÿฆ…๐Ÿ˜ก๐Ÿ˜บ๐Ÿš†๐Ÿ‘๐Ÿ•ก๐Ÿฆž๐Ÿ“๐Ÿ–Š๐Ÿ™€๐Ÿฆ‰ | ecoji -d | openssl base64
GhAkTyOY/Pta78KImgvofylL19M=
$ cat encode.go  | openssl dgst -binary -sha1 | openssl base64
GhAkTyOY/Pta78KImgvofylL19M=

(If you want to use Ecoji for hashes, consider the dangers inherent in older systems without utf8 emoji support, different fonts, and similar emojis.)

A URL Shortener

Four base1024 emojis can represent 1 trillion unique IDs. In the example below af82dd48f7 represents a 5 byte id for a URL in a key value store like Accumulo. When someone enters the URL, the 5 byte id could be used to obtain the actual URL from the database and then redirect.

$ printf "https://ecoji.io/%s\n" $(echo af82dd48f7 | xxd -r -p | ecoji)
https://ecoji.io/๐Ÿ˜‰๐Ÿˆš๐Ÿ› ๐Ÿ„

Sorting Ecoji-Encoded Data

Data encoded with Ecoji sorts the same as the input data.

$ echo -n a | ecoji > /tmp/test.ecoji
$ echo -n ab | ecoji >> /tmp/test.ecoji
$ echo -n abc | ecoji >> /tmp/test.ecoji
$ echo -n abcd | ecoji >> /tmp/test.ecoji
$ echo -n ac | ecoji >> /tmp/test.ecoji
$ echo -n b | ecoji >> /tmp/test.ecoji
$ echo -n ba | ecoji >> /tmp/test.ecoji
$ export LC_ALL=C
$ sort /tmp/test.ecoji > /tmp/test-sorted.ecoji
$ diff /tmp/test.ecoji /tmp/test-sorted.ecoji
$ cat /tmp/test-sorted.ecoji
๐Ÿ‘•โ˜•โ˜•โ˜•
๐Ÿ‘–๐Ÿ“ฒโ˜•โ˜•
๐Ÿ‘–๐Ÿ“ธ๐ŸŽˆโ˜•
๐Ÿ‘–๐Ÿ“ธ๐ŸŽฆโšœ
๐Ÿ‘–๐Ÿ”ƒโ˜•โ˜•
๐Ÿ‘™โ˜•โ˜•โ˜•
๐Ÿ‘š๐Ÿ“ขโ˜•โ˜•

Implementations

Libraries implementing the Ecoji encoding standard. Submit PR to add a library to the table.

Language Comments
D Implementation of Ecoji written in the D programming language.
Go This repository offers a Go library package with two functions ecoji.Encode() and ecoji.Decode().
Java Implementation of Ecoji written in Java, usable in any JVM language.
.NET Implementation of Ecoji written in C# targeting .NET Standard 2.0: dotnet add package Ecoji.
PHP PHP 7.x implementation of Ecoji. Available as rayne/ecoji on Packagist.
Python Implementation of Ecoji written in the Python3 programming language.
Rust Implementation of Ecoji written in the Rust programming language.
Swift Implementation of Ecoji written in the Swift programming language.

Building

This is my first Go project and I am starting to get my bearings. If you are new to Go I would recommend this video and the tour.

# The following are general Go setup instructions.  Ignore if you know Go, I am new to it.
export GOPATH=~/go
export PATH=$GOPATH/bin:$PATH

# This will download Ecoji to $GOPATH/src
go get github.com/keith-turner/ecoji

# This will build the ecoji command and put it in $GOPATH/bin
go install github.com/keith-turner/ecoji/cmd/ecoji

ecoji-1's People

Contributors

keith-turner avatar netvl avatar mecforlove avatar abock avatar ctubbsii avatar rayne avatar phrocker avatar pmkielstra avatar robindiddams avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.