forked from jtwaleson/decrypt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecrypt.py
More file actions
executable file
·61 lines (55 loc) · 1.45 KB
/
decrypt.py
File metadata and controls
executable file
·61 lines (55 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python
import curses
import time
import fileinput
import random
import string
lines = []
chance = 0.1
confirmed_per_line = []
screen = curses.initscr()
curses.noecho()
try:
curses.curs_set(0)
except:
pass
screen.keypad(1)
def iterate(increase = False):
still_random = 0
global chance, confirmed_per_line, lines
if increase:
chance += 0.01
screen.erase()
(y,x) = screen.getmaxyx()
final_line = len(lines)
if final_line > y:
first_line = final_line - y
else:
first_line = 0
for line_num in range(first_line, final_line):
line = lines[line_num]
for i in [i for i in range(min(x, len(line))) if i not in confirmed_per_line[line_num]]:
still_random += 1
if random.random() < chance:
confirmed_per_line[line_num].append(i)
random_line = ''.join(random.choice(string.punctuation) if col not in confirmed_per_line[line_num] else line[col] for col in range(min(len(line), x)))
try:
screen.addstr(line_num - first_line, 0, random_line)
except Exception:
pass
screen.refresh()
time.sleep(0.1)
return still_random > 0
try:
for line in fileinput.input():
confirmed_per_line.append([])
lines.append(line.rstrip())
iterate()
fileinput.close()
while iterate(True):
pass
time.sleep(2)
finally:
curses.endwin()
for line in lines:
print(line)