-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcipher.py
More file actions
23 lines (21 loc) · 860 Bytes
/
Copy pathcipher.py
File metadata and controls
23 lines (21 loc) · 860 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from round_functions import *
from helper_functions import *
from feistel_structure import feistel
def layered_link_cipher(input, mode, key):
extended_keys = []
key_generation(key, 1, extended_keys)
if mode=='encryption':
blocks = string_encryption(input)
ciphertexts = []
for i in blocks:
ciphertexts.append(feistel(i,extended_keys, round_function, xor_hex_strings, 'encryption'))
ciphertext = ''.join(ciphertexts)
return ciphertext
elif mode=='decryption':
ciphertexts = divide_into_blocks(input)
plaintexts = []
for i in ciphertexts:
plaintexts.append(feistel(i,extended_keys, round_function, xor_hex_strings, 'decryption'))
plaintext = ''.join(plaintexts)
plaintext = string_decryption(plaintext)
return plaintext