首页 > 编程语言 >基于python的Base全家桶解码

基于python的Base全家桶解码

时间:2023-04-24 18:22:21浏览次数:29  
标签:编码 python 解码 base64 decode Base print data


https://www.cnblogs.com/0yst3r-2046/p/11962942.html
 

函数介绍

  1. base64.b16encode  # 对字符串进行base16编码
  2. base64.b16decode  # 对字符串进行base16解码
  3. base64.b32encode  # 对字符串进行base32编码
  4. base64.b32decode  # 对字符串进行base32解码
  5. base58.b58encode  # 对字符串进行base58解码
  6. base58.b58decode  # 对字符串进行base58解码
  7. base64.b64encode  # 对字符串进行base64解码
  8. base64.b64decode  # 对字符串进行base64解码
  9. base64.a85encode  # 对字符串进行base85编码
  10. base64.a85decode  # 对字符串进行base85解码
  11. base91.encode    # 对字符串进行base91编码
  12. base91.decode    # 对字符串进行base91解码
  13. py3base92.encode  # 对字符串进行base92编码
  14. py3base92.decode  # 对字符串进行base92解码
  15. b128.encode     # 对字符串进行base128编码
  16. b128.decode     # 对字符串进行base128解码

 

1、base16

import base64

data = 'test{123456}'
sec = str.encode(data, 'utf-8')
c = base64.b16encode(sec)
print(c)  # 输出base16编码后的结果
m = base64.b16decode(c)
print(m)  # 输出base16解码后的结果

  

2、base32

import base64

data = 'test{123456}'.encode('utf-8')
sec = base64.b32encode(data)
print(sec)  # 输出base32编码后的结果
flag = base64.b32decode(sec)
print(flag)  # 输出base32解码后的结果

  

3、base36

import base36

# pip install base36
data = 'test123456'
m = base36.loads(data)  # 编码
c = base36.dumps(int(m))  # 解码
print(m)  # 输出编码后的结果
print(c)  # 输出解码后的结果

  

4、base58

import base58

# pip install base58
data = 'test{123456}'
m = base58.b58encode(data.encode('utf-8')).decode()  # base58编码
c = base58.b58decode(m).decode()  # base58解码
print(m)  # 输出编码后的结果
print(c)  # 输出解码后的结果

  

5、base64

import base64

data = 'test{123456}'
m = base64.b64encode(data.encode('utf-8')).decode()  # 编码
c = base64.b64decode(m).decode()  # 解码
print(m)  # 输出编码后的结果
print(c)  # 输出解码后的结果

  

6、base85

import base64

data = 'test{123456}'
m = base64.a85encode(data.encode('utf-8')).decode()  # 编码
c = base64.a85decode(m).decode()  # 解码
print(m)  # 输出编码后的结果
print(c)  # 输出解码后的结果

  

7、base91

import base91

# pip install base91
data = 'test{123456}'
m = base91.encode(data.encode('utf-8'))  # 编码
c = base91.decode(m).decode()  # 解码
print(m)  # 输出编码后的结果
print(c)  # 输出解码后的结果

  

8、base92

import py3base92

data = 'test{123456}'
sec = str.encode(data, 'utf-8')
m = py3base92.encode(sec)  # 编码
print(m)  # 输出编码后的结果
c = py3base92.decode('F#S<YRW^.DFd=<\\')  # 解码
print(c)  # 输出解码后的结果


旧的base92库已经不支持了,需要用py3base92库,这个库也不是python的内置库,需要把库下载下来手动安装。

https://github.com/Gu-f/py3base92/releases/tag/1.0.3-1
Windows下载下来后解压,直接双击install.bat即可安装成功。
Linux直接运行命令:python3 setup.py install

   

9、base128

import base128

# pip install base128 
data = 'test{123456}'
b128 = base128.base128(chars=None, chunksize=7)
m = list(b128.encode(data.encode(encoding="utf-8")))  # 编码
c = b''.join(b128.decode(m)).decode()  # 解码
print(m)  # 输出编码后的结果
print(c)  # 输出解码后的结果

  

 

标签:编码,python,解码,base64,decode,Base,print,data
From: https://www.cnblogs.com/pywen/p/17350418.html

相关文章

  • Python教程:协程、异步
    协程,又称作Coroutine。从字面上来理解,即协同运行的例程,它是比是线程(thread)更细量级的用户态线程,特点是允许用户的主动调用和主动退出,挂起当前的例程然后返回值或去执行其他任务,接着返回原来停下的点继续执行。yield语句实现函数执行到一半返回等会又跑到原来的地方继续执行。yiel......
  • Ubuntu系统python连接hive遇到的一些问题
    1.第一个问题,sasl这个库安装不上,报缺少sasl.h的问题(#include<sasl/sasl.h>)解决方法:sudoapt-getinstall-ylibsasl2-devgccpython-dev2.第二个问题,连接的时候报CouldnotstartSASL:b‘Errorinsasl_client_start(-4)SASL(-4)解决办法:sudoaptinstalllibsasl2-mod......
  • python zipfile解压文件出现中文乱码
    解压文件首先要在编写代码的开头通过import关键字来调用zipfile,再用with开头的命令来处理需要解压的文件。解决乱码情况可以通过自己创建文件夹的方式来解决,先创建一个自己的解压目录,为了区分是文件还是文件夹要获取文件大小,再把解码方式为cp437变成gbk,再对文件进行拼接,示例如下:......
  • dbever破解码
    aYhAFjjtp3uQZmeLzF3S4H6eTbOgmru0jxYErPCvgmkhkn0D8N2yY6ULK8oT3fnpoEu7GPny7csNsXL1g+D+8xR++/L8ePsVLUj4du5AMZORr2xGaGKG2rXa3NEoIiEAHSp4a6cQgMMbIspeOy7dYWX699Fhtpnu1YBoTmoJPaHBuwHDiOQQk5nXCPflrhA7lldA8TZ3dSUsj4Sr8CqBQeS+2E32xwSniymK7fKcVX75qnuxhn7vUY7YL2UY......
  • python pyinstaller库
    简要pyinstaller模块主要用于python代码打包成exe程序直接使用,这样在其它电脑上即使没有python环境也是可以运行的。用法一.安装pyinstaller属于第三方库,因此在使用的时候需提前安装pipinstallpyinstaller二.配置spec文件1.配置生成exe程序文件夹(1)如果不熟悉spec配置......
  • eNotInDatabase,btr.AppendEntity(attNew);必须在AddNewlyCreatedDBObject前面
     publicstaticvoidAddAttsToBlock(thisObjectIdblockId,List<AttributeDefinition>atts,boolcopyEntity=false){EntityattNew;Databasedb=blockId.Database;//获取数据库对象//打开块表记录为写......
  • python入门编程1
    最近迅速看了以下推荐的两本Python入门书籍:1.Python编程:从入门到实践2.Python编程快速上手——让繁琐工作自动化两本书的前半部分内容相似,都是些简单的基础知识,后半部分是些实践项目,但是从我的感受来看,项目内容组织的还是有点大,比如其中一个web项目开发,对于新手来说,里面包含的......
  • python三角网格划分示例
    python三角网格划分示例 importnumpyasnpimportturtle#输入三角形的边长length=float(input("Enterthelengthofthetriangle:"))#计算最短边、最长边和三角形个数short_side=lengthmax_side=length+lengthn=int(max_side/s......
  • python linux服务器上运行
    后台运行python脚本/opt/njzf/bsp/python37/python37/bin/python3.7main.py>result.log2>&1&说明:1.末尾的“&”:表示后台运行程序2.“nohup”:保证程序不被挂起3.“python”:是执行python代码的命令4.“-u”:表示不启用缓存,实时输出打印信息到日志文件(如果不加-u,则会导致......
  • 求解三维装箱问题的启发式深度优先搜索算法(python)
    ⭐️问题描述给定一个容器(其体积为VVV)和一系列待装载的箱子,容器和箱子的形状都是长方体。问题的目标是要确定一个可行的箱子放置方案使得在满足给定装载约束的情况下,容器中包含的箱子总体积SSS尽可能的大,即填充率尽可能的大,这里填充率指的是S/V∗100%S/V*100\%S/V∗......