跳转到主要内容

使用emoji可视化哈希和字节。

项目描述

Hashmoji是一个简单的Python 3程序和库,用于将内容哈希以emoji的形式可视化。

关于

Hashmoji实际上只是一个可执行的玩笑。它不是为了安全或满足严肃业务需求而设计的。但它是有趣的alpha质量内容,你可能喜欢。

安装

确保您已安装Python 3。在Mac OS X上,您可以通过homebrew安装Python 3

brew update
brew install python3

一旦您安装了Python 3,您就可以克隆此存储库并安装它

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

如果您有PIP(推荐)

pip3 install hashmoji

您还可能想要考虑在Virtualenv中安装Hashmoji

命令行用法

Hashmoji既可以作为一个可执行实用程序,也可以作为一个Python模块,您可以使用它来可视化来自hashlib或任何可被4字节整除的字节对象的输出。

要像sha1sum一样使用hashmoji

$ hashmoji.py README.rst
🐹 🌈 🆎 😊🔢

要查看所有可用选项,请运行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)

您可以使用hashlib提供的算法中的特定哈希算法

$ hashmoji.py -a sha512 README.rst
👵 🚁 😮 🕞 🇩🇪 🔶 🌊 🚫 🎍 🔞 ✔ 🆚 🎁 🚜 🍢🎋

在0.1.2版本中新增,您还可以省略FILE并使用stdin将hashmoji管道化。这在与十六进制格式结合使用时特别有用,可以可视化包含单行十六进制编码数据的程序输出,如gitmd5 -q

$ git rev-parse HEAD | hashmoji.py -x
♦ 🐢 👣 👸🀄

Hashmoji仅在Mac OS X 10.8和10.9的Terminal.app中进行了测试。它肯定在screen会话中无法工作。请相信我。

库使用

Hashmoji设计用于与字节对象或hashlib摘要一起使用

>>> 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)
'🏆 💙 🌀 🍒 🕕 🐯 💃 🎡 ⚡ 🔙 🚐 ➗ 🐟 ➡ 👍🏭'

测试

如果您有 setuptools

$ python3 setup.py test

如果您有 nose

$ nosetests

如果您两者都没有

$ python3 tests.py

待办事项

  • 有时要更智能地避免将文件内容加载到内存中。

许可

Hashmoji 在 3-clause BSD 许可证下发布。

项目详情


下载文件

下载您平台的文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。

源分布

hashmoji-0.1.3.tar.gz (9.1 kB 查看哈希值)

上传时间 源代码

构建分布

hashmoji-0.1.3-py2.py3-none-any.whl (16.2 kB 查看哈希值)

上传时间 Python 2 Python 3

由以下提供支持