rebus-生成仅由字母数字符号组成的base64编码字符串。
rebus的Python项目详细描述
生成仅由字母数字符号组成的base64编码字符串。
为什么我要制作这个应用程序?
最近我一直在致力于为plone实现一个Google Authenticator应用程序(我 是为我心爱的公司做的。
为了生成条码图像,我需要一个base32编码的字符串。而安卓 设备可以完美地扫描我生成的所有条形码图像,苹果设备 会在使用包含 一个或多个“=”字符
找到的解决方案是在要编码的字符串末尾添加一个数字
如果你碰巧遇到类似的问题,你知道该怎么做。
先决条件
- Python2.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
用法和示例
使用反驳是非常容易的只要你想使用base64.b32encode 或者base64.b64encode,将base64替换为rebus。
编码
必需进口
>>> import rebus
B32编码字符串
>>> rebus.b32encode('abcdefg') 'MFRGGZDFMZTQUCQK'
B64编码字符串
>>> rebus.b64encode('abcdefg') 'YWJjZGVmZwoK'
urlsafe_b64encode
>>> rebus.urlsafe_b64encode('abcdefg') 'YWJjZGVmZwoK'
解码
可以对字符串进行解码,使用rebus将其编码为原始值。
必需的导入
>>> import rebus
B32代码字符串
>>> rebus.b32decode('MFRGGZDFMZTQUCQK') 'abcdefg'
B64解码字符串
>>> rebus.b64decode('YWJjZGVmZwoK') 'abcdefg'
urlsafe_b64编码
>>> rebus.urlsafe_b64decode('YWJjZGVmZwoK') 'abcdefg'
许可证
gpl 2.0/lgpl 2.1
支架
如有任何问题,请通过作者部分中提供的电子邮件与我联系