python-加密(base64)
import base64 #base64也是用来加密的,但是这个是可以解密的
s = "username"
byte类型print(base64.b64encode(s.encode()) ) #加密
new_s = base64.b64encode(s.encode())
old_s = base64.b64decode(new_s).decode()) def bs64_data_encode(st):
salt='jmy12345'
new_str = str(st)+salt
encode_str = base64.b64encode(new_str.encode()).decode()
return encode_str
print(bs64_data_encode('老宋'))
def bs64_data_decode(st):
salt='jmy12345'
res = base64.b64decode(st).decode()
res = res.replace(salt,'')
return res
print(bs64_data_decode('6ICB5a6Lam15MTIzNDU='))
python-加密(base64)的更多相关文章
- hashlib python 加密框架
python3中digest()和hexdigest()区别 转自:https://www.cnblogs.com/yrxns/p/7727471.html hashlib是涉及安全散列和消息摘要,提 ...
- Python加密与解密
前言 据记载,公元前400年,古希腊人发明了置换密码.1881年世界上的第一个电话 保密专利出现.在第二次世界大战期间,德国军方启用“恩尼格玛”密码机, 密码学在战争中起着非常重要的作用. 随着信息化 ...
- Python解码base64遇到Incorrect padding错误
Python解码base64遇到Incorrect padding错误 base64转码过程 先说一下转换过程,详细的可以参考阮一峰.廖雪峰博客: 所谓Base64,就是说选出64个字符----小写字 ...
- 自己用 python 实现 base64 编码
自己用 python 实现 base64 编码 base64 编码原理 二进制文件中包含有很多无法显示和打印的字符,二进制的数据一般以 ASCII 码形式(8 bit,即一个字节)存储,8 bit 可 ...
- Python 加密 shellcode 免杀
Python 加密 shellcode 免杀 环境准备: Windows7 32 位系统: Shellcode 使用 kali linux Metasploit 生成 shellcode Wind ...
- python实现base64算法加密
python本身有base64加密的模块,不过是用C写的,封装成了.so文件,无法查看源码,本着学习的心态,自己实现了一遍,算法 原理参考 浅谈Base64编码算法. 代码如下: # coding:u ...
- python 应用 base64、hmac、hashlib包实现:MD5编码 base64编码解码、SHA256编码、urlsafe_b64encode编码等等基本所有的加密签名的方法
用python做HTTP接口自动化测试的时候,接口的很多参数是经过各种编码加密处理后在传到后台的,这里列举出python实现 应用 base64.hmac.hashlib包实现:md5编码 sha1编 ...
- python 加密解密(base64, AES)
1. 使用base64 s1 = base64.encodestring('hello world') s2 = base64.decodestring(s1) print s1, s2 结果 1 2 ...
- Python AES - base64 加解密
首先python引用AES加密 from Crypto.Cipher import AES 需要先安装 Crypto 模块, 可以使用 easy_install 进行安装 会自动去官网进行搜索 ...
- 用 Python 加密文件
生活中,有时候我们需要对一些重要的文件进行加密,Python 提供了诸如 hashlib,base64 等便于使用的加密库. 但对于日常学习而言,我们可以借助异或操作,实现一个简单的文件加密程序,从而 ...
随机推荐
- C#GC垃圾回收和析构函数和IDisposable的使用
一,什么是GC 1,GC是垃圾回收器,一般来说系统会自动检测不会使用的对象或变量进行内存的释放,不需要手动调用,用Collect()就是强制进行垃圾回收,使内存得到及时的释放,让程序效率更高. 2,G ...
- wordpress数据库结构以及数据表之间的关系
默认WordPress一共有以下11个表.这里加上了默认的表前缀 wp_ . wp_commentmeta:存储评论的元数据 wp_comments:存储评论 wp_links:存储友情链接(Blog ...
- 解决Chrome浏览器无法自动播放音频视频的问题,Uncaught (in promise) DOMException
转载自:http://www.nooong.com/docs/chrome_video_autoplay.htm 在最新版的Chrome浏览器(以及所有以Chromium为内核的浏览器)中,已不再允许 ...
- 七、latex中的插图
- python基础操作---list
#coding:utf-8 list1 = ['physics', 'chemistry', 1997, 2000]; list2 = [1, 2, 3, 4, 5 ]; list3 = [" ...
- windows下挂载NFS共享目录
1.在打开或关闭Windows功能中,选择安装NFS客户端 2.在命令行中,输入“mount \\172.24.184.31\data x:\”,输入mount查看详细挂载参数(注意此时uid.gid ...
- [ZJOI2006]物流运输(动态规划,最短路)
[ZJOI2006]物流运输 题目描述 物流公司要把一批货物从码头A运到码头B.由于货物量比较大,需要n天才能运完.货物运输过程中一般要转停好几个码头.物流公司通常会设计一条固定的运输路线,以便对整个 ...
- Django【第20篇】:Ajax
初始Ajax 一.Ajax准备知识:json 说起json,我们大家都了解,就是python中的json模块,那么json模块具体是什么呢?那我们现在详细的来说明一下 1.json(Javascrip ...
- JavaWeb DOM1
一.BOM的概述 browser object modal :浏览器对象模型. 浏览器对象:window对象. Window 对象会在 <body> 或 <frameset> ...
- 【leetcode】1177. Can Make Palindrome from Substring
题目如下: Given a string s, we make queries on substrings of s. For each query queries[i] = [left, right ...