class signature(object): def __init__(self, publickeystr): self.key = PublicKeyAlgorithm(publickeystr) def new(self, message, digestmod="whirlpool", raw=False): msghash = Hash(digestmod, message).digest() try: signraw = self.key.sign(msghash) except Exception, e: raise Exception("Unable to sign, error: %s" % e) signature = {"Type": "Signature", "Digest_Method": digestmod, "Data": signraw} if raw: return signature else: return serializer.dumps(signature)