Ejemplo n.º 1
0
def Decrypt_all_blocks(ciphertext, key, IV):
    ciphertext_list = Core.convert_to_block(ciphertext)
    Bit_List = Core.convert_to_ASCII(ciphertext_list)
    plain = []
    temp = IV[:]
    for block in Bit_List:
        AfterDecrypt = decrypt_block(block, key)
        plain_block = Core.XOR_previous_block(AfterDecrypt, temp)
        plain.append(plain_block)
        temp = block
    DecryptedText = Core.convert_all_blocks_to_chars(plain)
    return DecryptedText
Ejemplo n.º 2
0
def Encrypt_all_blocks(plaintext, key):
    plaintext_list = Core.convert_to_block(plaintext)
    Bit_List = Core.convert_to_ASCII(plaintext_list)
    IV = Core.keyGenerator()
    temp = IV[:]
    cipher = []
    for block in Bit_List:
        AfterXOR = Core.XOR_previous_block(block, temp)
        cipher_block = encrypt_block(AfterXOR, key)
        cipher.append(cipher_block)
        temp = cipher_block
    EncryptedText = Core.convert_all_blocks_to_chars(cipher)
    return IV, EncryptedText