用emoji可视化散列和字节。

hashmoji的Python项目详细描述


hashmoji是一个简单的python 3程序和库,用于将内容哈希可视化为emoji。

关于

hashmoji其实只是一个可执行的笑话。它不是为了安全或满足严重的需求 生意。但这是有趣的阿尔法质量的东西,你可能会喜欢。

安装

确保已安装Python 3。在Mac OS X上,您可以安装 通过自制的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只在Terminal.app中的macosx10.8和10.9上测试过它在屏幕会话中肯定不起作用。相信我

库使用

hashmoji被设计用于处理bytes对象或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)
'? ? ? ? ? ? ? ? ⚡ ? ? ➗ ? ➡ ??'

测试

如果您有setuptools

$ python3 setup.py test

如果你有nose

$ nosetests

如果两者都没有:

$ python3 tests.py

待办事项

  • 有时不要将文件内容加载到内存中。

许可证

Hashmoji是根据3条BSD许可证发布的

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java apache Jclouds与quarkus兼容吗?   java Switch语句和字符串到字节   java在Windows中处理unix路径   java将XML中的不同值插入数据库表   Android Room中带日期的java查询   java如何将vaadin7与googlemap连接起来   java有条件地忽略特定属性DTO   数据库中的java Spring最后一个ID作为JSP中的默认输入值。。怎样   java创建和使用匿名可运行类的最佳方法   关于布尔语句中参数的java问题   java JMH:无法创建SecurityManager:worker。组织。格拉德尔。过程内部的工人小孩BootstrapSecurityManager   JavaXMLStreamReader编码   java Hibernate空指针位于AbstractUserTypeHibernateIntegrator用户类型   安卓支持v7。小装置。在使用安卓 studio的java文件中找不到工具栏?   java从res文件夹中读取名为的文件(从变量读取)   java如何解决“图形设备初始化失败:d3d、sw”问题   java字节缓冲区可以用作“长寿”静态对象吗?   java如何获取currentlyloggedin用户的用户名   java如何优雅地检测SSL