Ejemplo n.º 1
0
def test_encrypt_decrypt_large(key):
    message = """Output FeedBack (OFB). This mode is very similar to CBC, but 
    it transforms the underlying block cipher into a stream cipher. The 
    keystream is the iterated block encryption of an Initialization Vector (IV).

    The IV is a data block to be transmitted to the receiver. The IV can be 
    made public, but it should be picked randomly.

    Reusing the same IV for encryptions done with the same key lead to 
    catastrophic cryptograhic failures."""
    out = crypt.encrypt(message, key)
    assert message == crypt.decrypt(out, key)
Ejemplo n.º 2
0
def test_encrypt_decrypt_large(key):
    message = """Output FeedBack (OFB). This mode is very similar to CBC, but 
    it transforms the underlying block cipher into a stream cipher. The 
    keystream is the iterated block encryption of an Initialization Vector (IV).

    The IV is a data block to be transmitted to the receiver. The IV can be 
    made public, but it should be picked randomly.

    Reusing the same IV for encryptions done with the same key lead to 
    catastrophic cryptograhic failures."""
    out = crypt.encrypt(message, key)
    assert message == crypt.decrypt(out, key)
Ejemplo n.º 3
0
def test_encrypt_decrypt_zero_bytes(key):
    message = ''.join(chr(int(c)) for c in '0' * crypt.BLOCK)
    out = crypt.encrypt(message, key)
    assert message == crypt.decrypt(out, key)
Ejemplo n.º 4
0
def test_encrypt_decrypt_small(key):
    message = "This is the message to encrypt"
    out = crypt.encrypt(message, key)
    assert message == crypt.decrypt(out, key)
Ejemplo n.º 5
0
def test_encrypt_decrypt_zero_bytes(key):
	message = ''.join(chr(int(c)) for c in '0' * crypt.BLOCK)
	out = crypt.encrypt(message, key)
	assert message == crypt.decrypt(out, key)
Ejemplo n.º 6
0
def test_encrypt_decrypt_small(key):
    message = "This is the message to encrypt"
    out = crypt.encrypt(message, key)
    assert message == crypt.decrypt(out, key)
Ejemplo n.º 7
0
def get_plaintext(filename, pass_key):
    try:
        with open(filename, 'rb') as f:
            return crypt.decrypt(f.read(), pass_key)
    except IOError:
        return ""