Пример #1
0
 def encode(self,source,key,iv="\0\0\0\0\0\0\0\0"):
     # obj=pyDes.des(self.getKey(key), pyDes.CBC, self.getIV(iv))
     if self.__action==TRIPLEDES:
         obj= pyDes.triple_des(self.getKey(key), self.__model, self.getIV(iv))
     else:
         obj= pyDes.des(self.getKey(key), self.__model, self.getIV(iv))
     return base64.encodestring(obj.encrypt(source,padmode=self.__padmodel))
Пример #2
0
 def decode(self,source,key,iv="\0\0\0\0\0\0\0\0"):
     if self.__action==TRIPLEDES:
         obj= pyDes.triple_des(self.getKey(key), self.__model,self.getIV(iv))
     else:
         obj= pyDes.des(self.getKey(key), self.__model,self.getIV(iv))
     source=base64.decodestring(source)
     return obj.decrypt(source,padmode=self.__padmodel)