资源简介
不依赖任何第三方库,完整支持python2(包括中英文),而python3仅支持纯英文,python3不能友好地支持中文。
代码片段和文件信息
#!python
# -*- coding:utf-8 -*-
#
# aes.py: implements AES - Advanced Encryption Standard
# from the SlowAES project http://code.google.com/p/slowaes/
#
# Copyright (c) 2008 Josh Davis ( http://www.josh-davis.org )
# Alex Martelli ( http://www.aleax.it )
#
# Ported from C code written by Laurent Haan ( http://www.progressive-coding.com )
#
# Licensed under the Apache License Version 2.0
# http://www.apache.org/licenses/
#
“““
公用函数(aes加密),仅支持 py2, 不支持py3(py3只支持纯英文)
Created on 2016/9/2
Updated on 2016/9/7
@author: Holemar
“““
import sys
import math
import random
class AES(object):
‘‘‘AES funtions for a single block
‘‘‘
# Very annoying code: all is for an object but no state is kept!
# Should just be plain functions in a AES modlule.
# valid key sizes
KeySize_128 = 16
KeySize_192 = 24
KeySize_256 = 32
# structure of supported modes of operation
MODE_OFB = 0
MODE_CFB = 1
MODE_CBC = 2
# Rijndael S-box
sbox = ( 0x630x7c0x770x7b0xf20x6b0x6f0xc50x300x010x670x2b0xfe0xd70xab0x76
0xca0x820xc90x7d0xfa0x590x470xf00xad0xd40xa20xaf0x9c0xa40x720xc0
0xb70xfd0x930x260x360x3f0xf70xcc0x340xa50xe50xf10x710xd80x310x15
0x040xc70x230xc30x180x960x050x9a0x070x120x800xe20xeb0x270xb20x75
0x090x830x2c0x1a0x1b0x6e0x5a0xa00x520x3b0xd60xb30x290xe30x2f0x84
0x530xd10x000xed0x200xfc0xb10x5b0x6a0xcb0xbe0x390x4a0x4c0x580xcf
0xd00xef0xaa0xfb0x430x4d0x330x850x450xf90x020x7f0x500x3c0x9f0xa8
0x510xa30x400x8f0x920x9d0x380xf50xbc0xb60xda0x210x100xff0xf30xd2
0xcd0x0c0x130xec0x5f0x970x440x170xc40xa70x7e0x3d0x640x5d0x190x73
0x600x810x4f0xdc0x220x2a0x900x880x460xee0xb80x140xde0x5e0x0b0xdb
0xe00x320x3a0x0a0x490x060x240x5c0xc20xd30xac0x620x910x950xe40x79
0xe70xc80x370x6d0x8d0xd50x4e0xa90x6c0x560xf40xea0x650x7a0xae0x08
0xba0x780x250x2e0x1c0xa60xb40xc60xe80xdd0x740x1f0x4b0xbd0x8b0x8a
0x700x3e0xb50x660x480x030xf60x0e0x610x350x570xb90x860xc10x1d0x9e
0xe10xf80x980x110x690xd90x8e0x940x9b0x1e0x870xe90xce0x550x280xdf
0x8c0xa10x890x0d0xbf0xe60x420x680x410x990x2d0x0f0xb00x540xbb0x16 )
# Rijndael Inverted S-box
rsbox = [0x52 0x09 0x6a 0xd5 0x30 0x36 0xa5 0x38 0xbf 0x40 0xa3
0x9e 0x81 0xf3 0xd7 0xfb 0x7c 0xe3 0x39 0x82 0x9b 0x2f
0xff 0x87 0x34 0x8e 0x43 0x44 0xc4 0xde 0xe9 0xcb 0x54
0x7b 0x94 0x32 0xa6 0xc2 0x23 0x3d 0xee 0x4c 0x95 0x0b
0x42 0xfa 0xc3 0x4e 0x08 0x2e 0xa1 0x66 0x28 0xd9 0x24
0xb2 0x76 0x5b 0xa2
- 上一篇:python svm 源码实现
- 下一篇:纯python实现的RC4加解密
相关资源
- Think Python 2nd
- 一个小小的表白程序(python)
- Python课堂笔记(高淇400集第一季)
- 二级考试python试题12套(包括选择题和
- pywin32_python3.6_64位
- python+ selenium教程
- PycURL(Windows7/Win32)Python2.7安装包 P
- 英文原版-Scientific Computing with Python
- 7.图像风格迁移 基于深度学习 pyt
- 基于Python的学生管理系统
- A Byte of Python(简明Python教程)(第
- Python实例174946
- Python 人脸识别
- Python 人事管理系统
- 基于python-flask的个人博客系统
- 计算机视觉应用开发流程
- python 调用sftp断点续传文件
- python socket游戏
- 基于Python爬虫爬取天气预报信息
- python函数编程和讲解
- Python开发的个人博客
- 基于python的三层神经网络模型搭建
- python实现自动操作windows应用
- python人脸识别(opencv)
- python 绘图(方形、线条、圆形)
- python疫情卡UN管控
- python 连连看小游戏源码
- 基于PyQt5的视频播放器设计
- 一个简单的python爬虫
- csv文件行列转换python实现代码
评论
共有 条评论