Exemplo n.º 1
0
def test_compressed_encrypt_then_decrypt_string():
    plaintext = "X" * 4096
    key = "this is my key"
    ciphertext = crypto.encrypt_string(plaintext, key, compress=True)
    assert_less(len(ciphertext), len(plaintext) / 10)
    plaintext_after = crypto.decrypt_string(ciphertext, key)
    assert_equal(plaintext, plaintext_after)
Exemplo n.º 2
0
def test_compressed_encrypt_then_decrypt_random_string():
    plaintext = os.urandom(1024 * 1024)
    key = "this is my key"
    ciphertext = crypto.encrypt_string(plaintext, key, compress=True)
    plaintext_after = crypto.decrypt_string(ciphertext, key)
    assert_equal(plaintext, plaintext_after)
Exemplo n.º 3
0
def test_encrypt_then_decrypt_empty_string():
    plaintext = ""
    key = "this is my key"
    ciphertext = crypto.encrypt_string(plaintext, key)
    plaintext_after = crypto.decrypt_string(ciphertext, key)
    assert_equal(plaintext_after, plaintext)
Exemplo n.º 4
0
def test_decrypt_with_wrong_password_raises_exception():
    plaintext = "this is some text"
    key = "this is my key"
    ciphertext = crypto.encrypt_string(plaintext, key)
    another_key = "this is my key 2"
    plaintext_after = crypto.decrypt_string(ciphertext, another_key)
Exemplo n.º 5
0
def test_decrypt_then_damage_raises_exception():
    plaintext = "this is some text"
    key = "this is my key"
    ciphertext = crypto.encrypt_string(plaintext, key)
    ciphertext = ciphertext[:len(ciphertext)-5]
    plaintext_after = crypto.decrypt_string(ciphertext, key)
Exemplo n.º 6
0
def test_encrypt_then_alter_raises_exception():
    plaintext = "this is some text"
    key = "this is my key"
    ciphertext = crypto.encrypt_string(plaintext, key)
    ciphertext = ciphertext[:-len(plaintext)] + '\0' * len(plaintext)
    plaintext_after = crypto.decrypt_string(ciphertext, key)
Exemplo n.º 7
0
def test_massive_encrypt_then_decrypt():
    plaintext = "X" * 50 * 1024 * 1024
    key = "this is my key"
    ciphertext = crypto.encrypt_string(plaintext, key)
    plaintext_after = crypto.decrypt_string(ciphertext, key)
    assert_equal(plaintext, plaintext_after)