用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第三方库


热门话题
Docker&SeleniumJava:无法在Docker容器上运行的chrome浏览器中上载图像/文件   在python中运行java命令   Java垃圾收集器异常行为   java java是否根据底层操作系统执行字节码级优化?   java是否可以休眠自定义查询返回映射而不是列表?   java Spring引导RabbitMQ接收器Jackson反序列化到POJO   apache flex在ActionScript3中创建对象相等“HashMap”作为java HashMap   java如何在Eclipse集成中切换JProfiler启动器   缓存JSP页面结果的java最佳实践?   java集成jaxb绑定文件,使用CXF生成基于WSDL的客户端   java为什么在上传操作结束之前,客户端没有检测到HttpServletResponse的PrintWriter内容?   java在接口内创建类和在类内创建接口有什么用   java向文件写入错误Android Studio   java合并多个RealmList并对结果列表排序?   谷歌API视觉java。lang.NoSuchMethodError   java如何使用逗号分别存储每个值,然后将它们存储到单独的数组中?