comparison easyhg.py @ 456:2f25cc7b81fa

Avoid bailing out on bogus data
author Chris Cannam
date Wed, 29 Jun 2011 16:22:53 +0100
parents 856da063d76e
children b09d0e6214d8
comparison
equal deleted inserted replaced
455:856da063d76e 456:2f25cc7b81fa
109 text += (16 - (len(text) % 16)) * ' ' 109 text += (16 - (len(text) % 16)) * ' '
110 ctext = base64.b64encode(self.auth_cipher.encrypt(text)) 110 ctext = base64.b64encode(self.auth_cipher.encrypt(text))
111 return ctext 111 return ctext
112 112
113 def decrypt(self, ctext): 113 def decrypt(self, ctext):
114 text = self.auth_cipher.decrypt(base64.b64decode(ctext)) 114 try:
115 (iv, d, text) = text.partition('.') 115 text = self.auth_cipher.decrypt(base64.b64decode(ctext))
116 (tlen, d, text) = text.partition('.') 116 (iv, d, text) = text.partition('.')
117 try: 117 (tlen, d, text) = text.partition('.')
118 return text[0:int(tlen)] 118 return text[0:int(tlen)]
119 except: 119 except:
120 self.ui.write("failed to decrypt/convert cached data!") 120 self.ui.write("failed to decrypt/convert cached data!")
121 return '' 121 return ''
122 122