Пример #1
0
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)
Пример #2
0
 def __init__(self, publickeystr):
     self.key = PublicKeyAlgorithm(publickeystr)