rebus - 仅由字母数字符号组成的base64编码字符串生成器。
项目描述
生成仅由字母数字符号组成的base64编码字符串。
为什么我制作了这个应用程序?
最近我一直在为Plone(我为心爱的公司 - Goldmund, Wyldebeast & Wunderliebe)实现Google Authenticator应用程序。
为了生成条形码图像,我需要一个base32编码的字符串。虽然Android设备可以完美地扫描我生成的所有条形码图像,但苹果设备会在使用包含一个或多个“=”字符的字符串生成的条形码图像上抛出错误。
找到的解决方案是在要编码的字符串末尾添加一些\n。
如果您遇到类似的问题,您知道该怎么做。
先决条件
Python 2.6.8+, 2.7.+, 3.3.+
安装
从PyPI安装最新稳定版本
$ pip install rebus
…或从GitHub获取最新稳定版本
$ pip install -e git+https://github.com/barseghyanartur/rebus@stable#egg=rebus
…或从BitBucket获取最新稳定版本
$ pip install -e hg+https://bitbucket.org/barseghyanartur/rebus@stable#egg=rebus
使用方法和示例
使用 rebus 非常简单。无论何时您想使用 base64.b32encode 或 base64.b64encode,将 base64 替换为 rebus。
编码
所需导入
>>> import rebus
b32encode 字符串
>>> rebus.b32encode('abcdefg') 'MFRGGZDFMZTQUCQK'
b64encode 字符串
>>> rebus.b64encode('abcdefg') 'YWJjZGVmZwoK'
urlsafe_b64encode
>>> rebus.urlsafe_b64encode('abcdefg') 'YWJjZGVmZwoK'
解码
可以解码使用 rebus 编码的字符串,还原其原始值。
所需导入
>>> import rebus
b32decode 字符串
>>> rebus.b32decode('MFRGGZDFMZTQUCQK') 'abcdefg'
b64decode 字符串
>>> rebus.b64decode('YWJjZGVmZwoK') 'abcdefg'
urlsafe_b64encode
>>> rebus.urlsafe_b64decode('YWJjZGVmZwoK') 'abcdefg'
许可协议
GPL 2.0/LGPL 2.1
支持
如有任何问题,请联系作者部分提供的电子邮件。
项目详情
rebus-0.2.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 9ca846a99019803fd52c0c34a12c5ee6598b763f956f105c503de738b6a0e4e5 |
|
MD5 | 880c140bd93e91ba4fbef2cdb279a313 |
|
BLAKE2b-256 | 6698ea0b70cd99617dfa501f1218aec0e1b42e4a4294c43e4d3533975e8d2f35 |