zoukankan      html  css  js  c++  java
  • 测试工具发布

    这是用工具来写的文章,不知道是否可行。

    from Crypto.Cipher import DES

    class MyDESCrypt:
       
        key = chr(11)+chr(11)+chr(11)+chr(11)+chr(11)+chr(11)+chr(11)+chr(11)
        iv = chr(22)+chr(22)+chr(22)+chr(22)+chr(22)+chr(22)+chr(22)+chr(22)
       
        def __init__(self,key='',iv=''):
            if len(key)> 0:
                self.key = key
            if len(iv)>0 :
                self.iv = iv
           
        def ecrypt(self,ecryptText):
           try:
               cipherX = DES.new(self.key, DES.MODE_CBC, self.iv)
               pad = 8 - len(ecryptText) % 8
               padStr = ""
               for i in range(pad):
                  padStr = padStr + chr(pad)
               ecryptText = ecryptText + padStr
               x = cipherX.encrypt(ecryptText)
               return x.encode('hex_codec').upper()
           except:
               return ""
         
      
        def decrypt(self,decryptText):
            try:
               
                cipherX = DES.new(self.key, DES.MODE_CBC, self.iv)
                str = decryptText.decode('hex_codec')
                y = cipherX.decrypt(str)
                return y[0:ord(y[len(y)-1])*-1]
            except:
                return ""

  • 相关阅读:
    yum命令速查
    5分钟理解编译系统
    Nginx(一)安装及启停
    Linux时间命令
    常用七种排序的python实现
    python迭代器、生成器、装饰器
    LeetCode【第217题】Contains Duplicate
    LeetCode【第1题】Two Sum
    python【第二十篇】Django表的多对多、Ajax
    不要问我DO在哪里?
  • 原文地址:https://www.cnblogs.com/dj258/p/5962894.html
Copyright © 2011-2022 走看看