位置: 编程技术 - 正文

python基于pyDes库实现des加密的方法(python pyb库)

编辑:rootadmin

推荐整理分享python基于pyDes库实现des加密的方法(python pyb库),希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:python库怎么用,python库怎么用,pythonsys库,python库教程,python .pyd,python库教程,python pyquery库,python pyquery库,内容如对您有帮助,希望把文章链接给更多的朋友!

本文实例讲述了python基于pyDes库实现des加密的方法。分享给大家供大家参考,具体如下:

下载及简介地址: setup.py --help可查看详细使用。

你可以使用命令python setup.py install命令安装,也可以直接将压缩包内的pyDes.py拷贝到本地的python lib库下直接开始使用

2、 使用

使用参数如下(拷贝自上述提供的地址):

python基于pyDes库实现des加密的方法(python pyb库)

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, or bytes for Triple DESmode -> 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 character (PAD_NORMAL) to use during all encrypt/decrpt operations done with this instance.padmode -> Optional argument, set the padding mode (PAD_NORMAL or PAD_PKCS5) to use during all encrypt/decrpt operations done with this instance.I recommend to use PAD_PKCS5 padding, as then you never need to worry about anypadding issues, as the padding can be removed unambiguously upon decryptingdata that was encrypted using PAD_PKCS5 padmode.

Common methods--------------encrypt(data, [pad], [padmode])decrypt(data, [pad], [padmode])data -> Bytes to be encrypted/decryptedpad -> Optional argument. Only when using padmode of PAD_NORMAL. For encryption, adds this characters to the end of the data block when data is not a multiple of 8 bytes. For decryption, will remove the trailing characters that match this pad character from the last 8 bytes of the unencrypted data block.padmode -> Optional argument, set the padding mode, must be one of PAD_NORMAL or PAD_PKCS5). Defaults to PAD_NORMAL

Example:

以下是本人使用的例子,使用CBC加密的方式:

PS:关于加密解密感兴趣的朋友还可以参考本站在线工具:

MD5在线加密工具: Socket编程技巧总结》、《Python函数使用技巧总结》、《Python字符串操作技巧汇总》、《Python入门与进阶经典教程》及《Python文件与目录操作技巧汇总》

希望本文所述对大家Python程序设计有所帮助。

Python实现通过文件路径获取文件hash值的方法 本文实例讲述了Python实现通过文件路径获取文件hash值的方法。分享给大家供大家参考,具体如下:importhashlibimportos,sysdefCalcSha1(filepath):withopen(filepath,'rb')

Python实现对字符串的加密解密方法示例 本文实例讲述了Python实现对字符串的加密解密方法。分享给大家供大家参考,具体如下:需求是是要将密码存在数据库里,所以要加密解密是可逆的,

Python在图片中添加文字的两种方法 本文主要介绍的是利用Python在图片中添加文字的两种方法,下面分享处理供大家参考学习,下来要看看吧一、使用OpenCV在图片中添加文字看上去很简单

本文链接地址:https://www.jiuchutong.com/biancheng/375584.html 转载请保留说明!

上一篇:Python简单实现Base64编码和解码的方法(python调用bash)

下一篇:Python实现通过文件路径获取文件hash值的方法(python用于读取文本文件内容的方法)

免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

鄂ICP备2023003026号

网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

友情链接: 武汉网站建设 电脑维修 湖南楚通运网络