def __init__(self, key, algo='sha1'): md = getattr(m2, algo, None) if md is None: raise ValueError, ('unknown algorithm', algo) self.md = md() self.ctx = m2.hmac_ctx_new() m2.hmac_init(self.ctx, key, self.md)
def __init__(self, key, algo="sha1"): md = getattr(m2, algo, None) if md is None: raise ValueError("unknown algorithm", algo) self.md = md() self.ctx = m2.hmac_ctx_new() m2.hmac_init(self.ctx, key, self.md)
def reset(self, key): m2.hmac_init(self.ctx, key, self.md)