码迷,mamicode.com
首页 > 其他好文 > 详细

base全家桶的安装使用方法

时间:2019-10-05 22:12:11      阅读:196      评论:0      收藏:0      [点我收藏+]

标签:get   base58   hex   lan   The   定时   blank   参数   ring   

base编码是Binary-to-text encoding的一种实现方法,它可以把二进制数据(含不可打印的字符)编码成可打印字符序列。

本文会不定时收录“base全家桶”:base64、base32、base16、base58、base91、base92等。

------------------

0x01 base64

安装:python2.7自带

alphabet:

ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/

padding:

=

使用:

import base64
c=base64.b64encode(pcat.cc)
m=base64.b64decode(c)
print c,m

 

0x02 base32

安装:python2.7自带

alphabet:

ABCDEFGHIJKLMNOPQRSTUVWXYZ234567

padding:

=

使用:

import base64
c=base64.b32encode(pcat.cc)
m=base64.b32decode(c)
print c,m

 

0x03 base16

安装:python2.7自带

alphabet:

0123456789ABCDEF

使用:

import base64
c=base64.b16encode(pcat.cc)
m=base64.b16decode(c)
print c,m

注意:

当b16decode的参数含有小写字母时,需要传入第二个参数True

base64.b16decode(706361742e6363,True)

或者使用python2.7的.decode(‘hex‘)则无须考虑大小写。

706361742e6363.decode(hex)

 

0x04 base58

github项目:https://github.com/keis/base58

安装:

pip install base58

alphabet:

123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz

使用:

import base58
c=base58.b58encode(pcat.cc)
m=base58.b58decode(c)
print c,m

 

0x05 base91

网址:http://base91.sourceforge.net/

github项目:https://github.com/aberaud/base91-python

安装:

pip install base91

alphabet:

ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&()*+,./:;<=>?@[]^_`{|}~"

使用:

import base91
c=base91.encode(pcat.cc)
m=base91.decode(c)
print c,m

 

0x06 base92

github项目:https://github.com/thenoviceoof/base92

安装:

pip install base92

alphabet:

!#$%&()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_abcdefghijklmnopqrstuvwxyz{|}

a special denotation (an empty string):

~

使用:

import base92
c=base92.encode(pcat.cc)
m=base92.decode(c)
print c,m

注意:

encode,b92encode,base92_encode是一样的,
decode,b92decode,base92_decode是一样的。

 

base全家桶的安装使用方法

标签:get   base58   hex   lan   The   定时   blank   参数   ring   

原文地址:https://www.cnblogs.com/pcat/p/11625834.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!