-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.py
28 lines (23 loc) · 849 Bytes
/
main.py
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
import sys, os, properties
print 'Make sure all look-up tables are placed correctly. \nEnter the number of'
print 'IN-bits: \t',
IN = int(raw_input())
print 'OUT-bits:\t',
OUT = int(raw_input())
properties.set_length(IN, OUT)
SB_COUNT = len(os.listdir('tables/'))
print 'There are ' + str(SB_COUNT) + ' files in tables. Enter \'N\' or \'n\' if incorrect, else press any other key to continue.'
ctr_valid = raw_input().lower()
if ctr_valid == 'n':
print 'Rerun after checking files.'
sys.exit()
for i in xrange(SB_COUNT):
filename = "sbox_" + str(i+1) + ".txt"
with open("tables/" + filename, 'r') as table:
look_up = table.read()
look_up = look_up.split()
output = properties.all_prop(look_up)
with open("results/" + filename, 'w') as result:
for j in xrange(OUT):
result.write(output[j])
print 'Results stored successfully.\n'