Skip to content

⌨️ Text processing toolkit for conversions, encoding, cipher translation, checksum calculation, hashing, encryption and formatting for developers and ARG enthusiasts.

License

MikeKovarik/Sombra

Repository files navigation

Sombra

⌨️ Text processing toolkit for conversions, encoding, cipher translation, checksum calculation, hashing, encryption and formatting for developers and ARG enthusiasts.

1NF:rM@7iON 1S P0vvErr

In anticipation of Overwatch's new character Sombra an ARG game was held by Blizzard. Ciphered clues and puzzles were hidden throughout the game and websites. To help with cracking them I have put together an app with various convertors, encoders and cipher translators. The ARG is now over but I'd still like to publish the app as it has shown to be useful when developing stuff, educational and simply fun to play with. First step on the road was to release this library of encoders/decoders that power it.

Note: The gif depicts an app that is not released yet. Hopefuly sometime in the future it will. And it is powered by this library.

Installation

npm install sombra

TODO require/import/<script>

Features

Convertors and translators

Text encoders

Numerical: Binary, Octal, Decimal, Hexadecimal, Base64, Custom radix

sombra.bin.encode('boop').toString() // 01100010 01101111 01101111 01110000
sombra.bin.encodeToString('boop') // 01100010 01101111 01101111 01110000
sombra.bin.encodeToString('boop', '-') // 01100010-01101111-01101111-01110000
sombra.hex.encodeToString('boop', ':') // 62:6f:6f:70

Entity escapers: NCR (HTML entities), Unicode

sombra.NcrDec.encode('<').toString('hex') // &#60;
sombra.Unicode.encode('💀').toString('hex') // U+1F480

Ciphers

Ceasar, clock, atbash, A1-Z26, morse code, and many more in the works or with preliminary implementation.

sombra.caesar.encodeToString('Avocados are useless.') // Xslzxalp xob rpbibpp.
sombra.morse.encodeToString('hello') // .... . .-.. .-.. ---

Checksums

CRC-16, CRC-32, xor, 2's complement, sum

sombra.crc32.encode('Avocados are useless.').toString('hex') // 71b3f376
sombra.crc32.encodeToString('Avocados are useless.') // 71b3f376
sombra.twosComplement.encodeToString('Avocados are useless.') // 26

Hashing algorithms

SHA-1, SHA-256, SHA-384, SHA-512, MD5 (where available)

var promise = sombra.Sha256.encode('Information is power')
promise.then(buffer => buffer.toString('hex'))
// c5a207aeb567728a4650ee49839a1007ac5bc1d9b09f4140de0bca658f2e05a7

Note: Web Crypto API does not support MD5 in browsers. It is only available in Node and UWP.

Isomorphic

This library can be used in both Node and browser. Even in UWP.

Data is is handled in Buffers in Node or (in browser) if the buffer module polyfill is used. Otherwise Sombra falls back to Uint8Array and all methods will accept and return Uint8Array.

Similarly crypto module is used in Node, Web Crypto API in browsers and Windows.Security.Cryptography namespace in UWP Windows apps.

Streams

All encoders/decoders are not only static methods on the class but the class itself is a Transform stream (where available) so you can .pipe() data through.

and it also has .update()/.digest() methods.

myReadStreamFromString('boop')
	// converts 'boop' to 'yllm'
	.pipe(new sombra.caesar.Encoder)
	// converts 'yllm' to '-.-- .-.. .-.. --'
	.pipe(new sombra.morse.Encoder)
	// hashes '-.-- .-.. .-.. --' to <Buffer eb 5c f0 a3 90 a1 88 98 38 dc ..>
	.pipe(new sombra.sha256.Encoder)
	// prints out the buffer as string 'eb5cf0a390a1889838dc1d870ff44aff05d440e9348a8f7308770db56939a551'
	.pipe(myConsoleWriteStream('hex'))

API

Not stabilized yet but the examples from above work just fine.

Work in progress. More sugar incoming.

Plans for the future

  • Finalizing API that's simple and sugar-coated.
  • More ciphers - Vigenere, rot13 (and variations), xor, bifid, etc... Some are already in works from before.
  • CRC variants (modbus, xmodem, kermit, etc...)
  • Vigenere cipher
  • ROT13 cipher
  • ROT13 variants
  • XOR cipher
  • Bifid cipher
  • Leet speak
  • BCD encoding
  • Unicode and NCR encoding
  • HTML/XML entity escaping
  • url / percentage encoding
  • properly handling and escaping UTF-8 & UTF-16

Note on special characters

Sombra, just like Browser's TextEncoder API or Node's Buffer (by default) works with Utf8 formatted strings. That means special characters will become represented by two or more bytes bytes. For example § = <Buffer c2 a7> and 💀 = <Buffer f0 9f 92 80>

Credits

Made by Mike Kovařík, Mutiny.cz

About

⌨️ Text processing toolkit for conversions, encoding, cipher translation, checksum calculation, hashing, encryption and formatting for developers and ARG enthusiasts.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published