AES加密,,[Python]代码fr
AES加密,,[Python]代码fr
[Python]代码
from Crypto.Cipher import AESclass mycrypt(): def __init__(self,key): self.key = key self.mode = AES.MODE_CBC def myencrypt(self,text): cryptor = AES.new(key,self.mode) length = 16 count = text.count('') if count < length: add = (length-count) + 1 text = text + (' ' * add) elif count > length: add = (length-(count % length)) + 1 text = text + (' ' * add) self.ciphertext = cryptor.encrypt(text) return self.ciphertext def mydecrypt(self,text): cryptor = AES.new(key,self.mode) plain_text = cryptor.decrypt(text) return plain_texttext = "98789khjsajfilahfpoiwufipoasufipo"key = "9878*(&^^&)0LLIu(*&^))#$@!KJLKJj"en = mycrypt(key)entext = en.myencrypt(text)print entextdetext = en.mydecrypt(entext).rstrip()print detext
相关内容
- 猜数游戏,猜数,[Python]代码de
- python抓取网页及网页上所有连接的演示代码,python抓取
- 查单词的脚本,单词脚本,#!/usr/bin/p
- Python xml和xsl转换为html,pythonxmlxslhtml,用的libxml2,所以
- 创建并修改excel,创建修改excel,[Python]代码#创
- python分页类,python分页,python分页类#co
- 简单验证码识别,验证码识别,get_CAPTCHA.
- 下载豆瓣音乐小站歌曲,豆瓣小站歌曲,[Python]代码#!
- python采集百度百科名片,,[Python]代码#!
- S先生与P先生谜题,谜题,[Python]代码de
评论关闭