it is complete
This commit is contained in:
1 parent
e115c7bee9
commit
039af0b541
1 file changed
+53
@@ -0,0 +1,53 @@
|
||||
from itertools import repeat
|
||||
import random
|
||||
import argparse
|
||||
import difflib
|
||||
from typing import Generator, Tuple
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
description="program that makes random ass keys for transformation of text"
|
||||
)
|
||||
|
||||
|
||||
## there is input file, output file and potentially a list of numbers from -256 to 256.
|
||||
|
||||
|
||||
def index_list(range: range, length: int, seed=None) -> Generator[int, None, None]:
|
||||
"put in a range obj (`range(1, 19, 2)`) for range"
|
||||
if seed is not None:
|
||||
random.seed(seed)
|
||||
return (random.choice(range) for _ in repeat(None, length))
|
||||
|
||||
|
||||
def funky_function(
|
||||
text_in, text_out, seed=None
|
||||
) -> Generator[Tuple[int, int], None, None]:
|
||||
range_text_in = range(len(text_in))
|
||||
len_text_out = len(text_out)
|
||||
for id_out, id_in in enumerate(index_list(range_text_in, len_text_out, seed)):
|
||||
val_in = text_in[id_in]
|
||||
val_out = text_out[id_out]
|
||||
yield id_in, ord(val_out) - ord(val_in)
|
||||
|
||||
|
||||
def rebuild(text_in, this: Generator[Tuple[int, int], None, None]):
|
||||
for ind, offset in this:
|
||||
val_in = text_in[ind]
|
||||
yield chr(ord(val_in) + offset)
|
||||
|
||||
|
||||
str1 = "hello world"
|
||||
# str1 = input("what is the message in: ")
|
||||
str2 = "this shit is ass"
|
||||
# str2 = input("what is the message out: ")
|
||||
|
||||
ahh_key = list(funky_function(str1, str2))
|
||||
|
||||
# print("the key:")
|
||||
print(ahh_key)
|
||||
# [(6, -3), (7, -7), (6, -14), (5, 83), (5, 0), (0, 11), (7, -7), (8, -9), (1, 15), (6, -87), (7, -6), (6, -4), (5, 0), (6, -22), (8, 1), (4, 4)]
|
||||
|
||||
# print("the key works:")
|
||||
print("".join(rebuild(str1, (i for i in ahh_key))))
|
||||
# this shit is ass
|
||||
Reference in new issue
Block a user