defgenerate_payload(source_data): a = "2" b = "12345678" c = md5(a + source_data + b) payload = c + "123456782" return payload
defread_data_from_file(file_path): withopen(file_path, 'r') as file: return file.readlines()
defsave_encrypted_data_to_file(encrypted_data, file_path): withopen(file_path, 'w') as file: for encrypted in encrypted_data: file.write(f"{encrypted}\n")
defsave_original_and_encrypted_data(data_pairs, file_path): withopen(file_path, 'w') as file: for original, encrypted in data_pairs: file.write(f"{original.strip()} : {encrypted}\n")
defprocess_data(input_file, encrypted_file, original_and_encrypted_file): data_pairs = [] encrypted_data = [] data_lines = read_data_from_file(input_file) for line in data_lines: encrypted = generate_payload(line.strip()) data_pairs.append((line.strip(), encrypted)) encrypted_data.append(encrypted) save_encrypted_data_to_file(encrypted_data, encrypted_file) save_original_and_encrypted_data(data_pairs, original_and_encrypted_file)