def generateSignature(priv, message):
    sha1 = hashlib.sha1()
    sha1.update(message)
    digest = sha1.digest()
    block = b'\x00\x01' + (b'\xff' * (128 - len(digest) - 3)) + b'\x00' + digest
    signature = challenge39.decryptbytes(priv, block)
    return signature
예제 #2
0
def generateSignature(priv, message):
    sha1 = hashlib.sha1()
    sha1.update(message)
    digest = sha1.digest()
    block = b'\x00\x01' + (b'\xff' * (128 - len(digest) - 3)) + b'\x00' + digest
    signature = challenge39.decryptbytes(priv, block)
    return signature
예제 #3
0
def decryptOnce(ciphertext):
    sha1 = hashlib.sha1()
    sha1.update(ciphertext)
    digest = sha1.digest()
    if digest in decryptedHashes:
        raise ValueError('Already decrypted')
    decryptedHashes.add(digest)
    return challenge39.decryptbytes(priv, ciphertext)
예제 #4
0
def decryptOnce(ciphertext):
    sha1 = hashlib.sha1()
    sha1.update(ciphertext)
    digest = sha1.digest()
    if digest in decryptedHashes:
        raise ValueError('Already decrypted')
    decryptedHashes.add(digest)
    return challenge39.decryptbytes(priv, ciphertext)
예제 #5
0
def generateSignature(priv, message):
    sha1 = hashlib.sha1()  #求哈希值
    sha1.update(message)  #
    digest = sha1.digest()  #sha1的摘要
    block = b'\x00\x01' + (
        b'\xff' *
        (128 - len(digest) - 3)) + b'\x00' + digest  #填充的方式 128-(摘要长度-3)
    signature = challenge39.decryptbytes(priv, block)  #私钥解密 = 签名
    return signature