Skip to main content

Visualize hashes and bytes with emoji.

Project description

Hashmoji is a simple Python 3 program and library for visualizing content hashes as emoji.

About

Hashmoji is really just an executable joke. It is not intended to be secure or meet the needs of Serious Business. But itโ€™s fun alpha-quality stuff that you may enjoy.

Installation

Make sure you have Python 3 installed. On Mac OS X you can install Python 3 via homebrew:

brew update
brew install python3

Once you have Python 3 installed you can clone this repository and install it:

git clone git@github.com:mcroydon/hashmoji.git
cd hashmoji
python3 setup.py install

Or if you have PIP (recommended):

pip3 install hashmoji

You may also want to consider installing Hashmoji in a Virtualenv.

Command-line usage

Hashmoji ships as both an executable utility and as a Python module that you can use to visualize output from hashlib or any bytes object divisible by 4 bytes.

To use hashmoji similar to sha1sum:

$ hashmoji.py README.rst
๐Ÿน ๐ŸŒˆ ๐Ÿ†Ž ๐Ÿ˜Š๐Ÿ”ข

To see all available options, please run hashmoji.py --help:

mattbookpro:hashmoji mcroydon$ python3 hashmoji.py -h
Usage: hashmoji.py [options] FILE or no arguments for stdin

Options:
  --version             show program's version number and exit
  -h, --help            show this help message and exit
  -a ALGORITHM, --algorithm=ALGORITHM
                        Use ALGORITHM from hashlib.  Choices: ['SHA512',
                        'sha512', 'sha384', 'ecdsa-with-SHA1', 'SHA256',
                        'dsaEncryption', 'SHA384', 'MDC2', 'SHA224',
                        'RIPEMD160', 'dsaWithSHA', 'MD4', 'sha', 'MD5',
                        'sha224', 'md4', 'md5', 'sha1', 'sha256', 'mdc2',
                        'DSA-SHA', 'ripemd160', 'DSA', 'SHA1', 'SHA']
  -n, --no-hash         Treat the content as binary data divisible by 4 bytes
                        suitable for conversion to emoji

  Format Options:
    -t, --text          Read the file in text mode (default).
    -b, --binary        Read the file in binary mode.
    -x, --hex           Read the file as hexidecimal encoded binary data, such
                        as a hexdigest.  Implies --no-hash.
    -e ENCODING, --encoding=ENCODING
                        Encoding to be used for text.  (default is utf-8)

You can use a specific hash algorithm based on the algorithms available to hashlib:

$ hashmoji.py -a sha512 README.rst
๐Ÿ‘ต ๐Ÿš ๐Ÿ˜ฎ ๐Ÿ•ž ๐Ÿ‡ฉ๐Ÿ‡ช ๐Ÿ”ถ ๐ŸŒŠ ๐Ÿšซ ๐ŸŽ ๐Ÿ”ž โœ” ๐Ÿ†š ๐ŸŽ ๐Ÿšœ ๐Ÿข๐ŸŽ‹

New in 0.1.2, you can also omit a FILE and pipe stdin to hashmoji. This is particularly useful when combined with hex format for visualizing the output of programs that include a single line of hex-encoded data such as git or md5 -q:

$ git rev-parse HEAD | hashmoji.py -x
โ™ฆ ๐Ÿข ๐Ÿ‘ฃ ๐Ÿ‘ธ๐Ÿ€„

Hashmoji has only been tested on Mac OS X 10.8 and 10.9 in Terminal.app. It definitely doesnโ€™t work inside a screen session. Trust me.

Library usage

Hashmoji is designed to work with either a bytes object or a hashlib digest:

>>> from hashmoji import hashmoji

# Use with hashlib
>>> import hashlib
>>> hashmoji(hashlib.sha1(b"This is my test string."))
'๐Ÿ“ฑ ๐Ÿ”ข ๐Ÿ“ฉ ๐Ÿšฆ๐Ÿ“ฒ'

# Use with bytes as long as the bytes are divisible by 4 bytes
>>> mybytes = b'\x916\xb8|\x1b\xf7&\xaa\x92(;OQX\x95^w\x1c\xb2\xd6\xbe\xb9_\x8b\xcf\xdcO\xa3\x8f\xcf\xdbq\x89\xd0\nF\xce1\x81\xca\xdd\x15\xf4\xe1\x10\x807\x19\x1b\x0f\xe8\x86\x08\xf7O\x19\xf1\x16\xf3\x93\x97\xfa{\x81'
>>> len(mybytes)
64
>>> len(mybytes) % 4
0
>>> hashmoji(mybytes)
'๐Ÿ† ๐Ÿ’™ ๐ŸŒ€ ๐Ÿ’ ๐Ÿ•• ๐Ÿฏ ๐Ÿ’ƒ ๐ŸŽก โšก ๐Ÿ”™ ๐Ÿš โž— ๐ŸŸ โžก ๐Ÿ‘๐Ÿญ'

Testing

If you have setuptools:

$ python3 setup.py test

If you have nose:

$ nosetests

If you have neither:

$ python3 tests.py

To Do

  • Be smarter about not loading file contents in to memory sometimes.

License

Hashmoji is released under a 3-clause BSD license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hashmoji-0.1.3.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

hashmoji-0.1.3-py2.py3-none-any.whl (16.2 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file hashmoji-0.1.3.tar.gz.

File metadata

  • Download URL: hashmoji-0.1.3.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for hashmoji-0.1.3.tar.gz
Algorithm Hash digest
SHA256 3eeda9bccf38882c67561b0fe13594676e2d8c4dbfa813fcdb7960e4213d14f2
MD5 470f36a1db90e73dde5fb5d9510b75d9
BLAKE2b-256 c20dbb18deb6269f01030db215febfadff533a74515b7414b9b2339123281a6b

See more details on using hashes here.

File details

Details for the file hashmoji-0.1.3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for hashmoji-0.1.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c72ac4d184c1e83e10c29ec0e61dd681ef7e41f602fd3fb7e35d40be832bbe18
MD5 8b97014deb9de0e14ec398eca54ec36a
BLAKE2b-256 7c95ceaddef33eeaf76ed562fdc6d03687fb04909e6f3780ab4017dbcc34c41f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page