标签:
如需要在python中使用des加密,可以直接使用pyDes库加密,该库提供了CBC和ECB两种加密方式。
1、Windows下安装
下载后pyDes-x.x.x.zip并解压后,里面有setup.py文件,使用命令 setup.py --help可查看详细使用。
你可以使用命令 python setup.py install 命令安装,也可以直接将压缩包内的pyDes.py拷贝到本地的python lib库下直接开始使用
2、 使用
使用参数如下(拷贝自上述提供的地址):
Class initialization
--------------------
pyDes.des(key, [mode], [IV], [pad], [padmode])
pyDes.triple_des(key, [mode], [IV], [pad], [padmode])
key -> Bytes containing the encryption key. 8 bytes for DES, 16 or 24 bytes
for Triple DES
mode -> Optional argument for encryption type, can be either
pyDes.ECB (Electronic Code Book) or pyDes.CBC (Cypher Block Chaining)
IV -> Optional Initial Value bytes, must be supplied if using CBC mode.
Length must be 8 bytes.
pad -> Optional argument, set the pad characte