Untitled
unknown
plain_text
a month ago
2.3 kB
1
Indexable
def polinom(n, m): i = 0 z = [] s = 0 while n > 0: if n % 2 != 0: z.append(2 - (n % 4)) else: z.append(0) n = (n - z[i]) / 2 i = i + 1 z = z[::-1] l = len(z) for i in range(0, l): s += z[i] * m ** (l - 1 - i) return s with open("polinom_results.txt", "w") as file: for number in range(1, 100): result = int(polinom(number, 3)) formatted_number = f"{number:02}" file.write(f"{formatted_number}:{result}\n") polinom_lookup = {} def is_valid_integer(s): if s == "0": return True return s.isdigit() and s[0] != '0' for i in range(10000): polinom_lookup[str(i)] = -1 with open('polinom_results.txt', 'r') as f: for line in f: number, result = line.strip().split(':') polinom_lookup[result] = number # Mapping results to numbers def recover_inputs(encrypted_text, current_position=0, current_input='', results=None): if results is None: results = [] if current_position == len(encrypted_text): # If we got to the end, we found a valid iflag results.append(current_input) return for length in range(1, 5): # Lengths 1-4 if current_position + length <= len(encrypted_text): prefix = encrypted_text[current_position:current_position + length] # Select the slice if is_valid_integer(prefix) == 0: # Skip invalid prefixes (like "01") continue if polinom_lookup[prefix] != -1: # If prefix exists in our lookup table new_input = current_input + polinom_lookup[prefix] recover_inputs(encrypted_text, current_position + length, new_input, results) return results encrypted_text = "242712673639869973827786401934639193473972235217215301" possible_inputs = recover_inputs(encrypted_text) for decimal_str in possible_inputs: decimal_value = int(decimal_str) // 100 * 10 + 1 # Correcting '01' to '1' hex_value = hex(decimal_value)[2:] try: original_text = bytes.fromhex(hex_value).decode('utf-8') print(f"{original_text}") break except Exception as e: pass
Editor is loading...
Leave a Comment