def hex(self, x): if self.algorithm == 'MD5': return hexmd5(x) elif self.algorithm == 'SHA1': return hexsha1(x) else: raise ValueError('Unknown algorithm %s' % self.algorithm)