示例#1
0
def _test_keys():
    e = _g_exponent
    n = rsa.hexpack(_g_public_key)
    d = rsa.hexpack(_g_private_key)
    pub = rsa.rsakey((_g_exponent, n))
    priv = rsa.rsakey((d, n))

    text = "jackdaw loves my big sphinx of quartz"
    print "plain text: ", len(text), text

    ctext = pub.encrypt(text)
    out = priv.decrypt(ctext)

    print "decrypted: ", len (out), out

    assert out == text
示例#2
0
def decrypt_binary(s):
    n = rsa.hexpack(_g_public_key)
    d = rsa.hexpack(_g_private_key)
    priv = rsa.rsakey((d, n))
    return priv.decrypt(s)