Пример #1
0
def test_encrypt_decrypt_large(n, p, q, e, d):
    def gen_bytes():
        for i in range(0, 5):
            fp = open('random.bytes', 'rb')
            while True:
                byte = fp.read(1)
                if byte:
                    yield byte
                else:
                    fp.close()
                    break
    encrypter = BinaryEncrypter(PrivateKey(p, q, e))
    for chunk in encrypter.encrypt(gen_bytes()): pass
Пример #2
0
def test_pubkey_encrypt_privkey_decrypt(n, p, q, e, d, plaintext):
    encrypter = BinaryEncrypter(PublicKey(n, e))
    decrypter = BinaryEncrypter(PrivateKey(p, q, e))
    ciphertext = b''.join(encrypter.encrypt(plaintext))
    assert plaintext == b''.join(decrypter.decrypt(ciphertext))