Skip to content

Commit

Permalink
encrypted output
Browse files Browse the repository at this point in the history
  • Loading branch information
ilias committed Jun 21, 2015
1 parent 351d1c3 commit cd3628f
Show file tree
Hide file tree
Showing 3 changed files with 1,287 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
*.aux
*.blg
*.log
*.out
*.toc
report/ref/*
report/ref/*
report/*.out
21 changes: 21 additions & 0 deletions code/fsm.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,30 @@ def process_outgoing(self, bits, cmd):
pass
return bits

def _print_enc(self, bits):
cur_ind = 0
set_bits = 0
cur_byte = 0
for bit in bits:
if cur_ind < 8:
cur_byte |= (bit << cur_ind)
cur_ind += 1
set_bits += bit
else:
if set_bits & 1 == bit: # OK
print format(cur_byte, "#04X") + "!",
else:
print format(cur_byte, "#04X"),

set_bits = cur_byte = cur_ind = 0

print ''

def _decrypt_bits(self, bits):
c = self._encryption
if c:
self._print_enc(bits)

start_bits = []
rem_bits = bits

Expand Down
Loading

0 comments on commit cd3628f

Please sign in to comment.