def read(self,s): try: s = unb64(s) except: raise ValueError("key must be base64 encoded.") if len(s)%2: raise ValueError("invalid key") k = s[0:len(s)/2] m = s[len(s)/2:] self.set(hexpack(k),hexpack(m))
def pdecrypt(self, s): i = self.crypt(hexpack(unb64(s))) return hexunpack(i)