python 实现 DES CBC模式加解密

python 实现 DES CBC模式加解密,第1张

概述    # -*- coding=utf-8-*-from Crypto.Cipher import DESimport base64"""des cbc加密算法padding : PKCS5"""class DESUtil: __BLOCK_SIZE_8 = BLOCK_SIZE_8 = DES.block_size __IV = "\0\0\0\

 

 

# -*- Coding=utf-8-*-from Crypto.Cipher import DESimport base64"""des cbc加密算法padding : PKCS5"""class DESUtil:    __BLOCK_SIZE_8 = BLOCK_SIZE_8 = DES.block_size    __IV = ""# __IV = chr(0)*8    @staticmethod    def encryt(str,key):        cipher __IV)        x __BLOCK_SIZE_8 __BLOCK_SIZE_8)        if 0:            str x        msg = DES.new(key,DES.MODE_CBC,DESUtil. cipher.encrypt(str)        #= DESUtil. msg = base64.urlsafe_b64encode(msg).replace(‘=‘,‘‘) - (len(str) % DESUtil. base64.b64encode(msg)        return msg    @staticmethod     x !=def= str + chr(x)*__IV=)        # enStr += (len(enStr) % 4)*"="        msg =# decryptByts = base64.urlsafe_b64decode(enStr) base64.b64decode(enStr)        msg  cipher.decrypt(decryptByts)        paddingLen  decrypt(enStr,DESUtil.])        returnpaddingLen]if        @R_403_4267@"        decryptByts =__main__="= ord(msg[len(msg)-1:    key " msg[0:-12345678"     res  == "123456",key)    = print# ED5wLgc3Mnw=print= DESUtil.encryt( res      DESUtil.decrypt(res,key)
总结

以上是内存溢出为你收集整理的python 实现 DES CBC模式加解密全部内容,希望文章能够帮你解决python 实现 DES CBC模式加解密所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/1191624.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-03
下一篇2022-06-03

发表评论

登录后才能评论

评论列表(0条)

    保存