Skip to content

Commit

Permalink
add my steganograph
Browse files Browse the repository at this point in the history
  • Loading branch information
Grigory Bakunov committed Aug 23, 2012
1 parent b5b2934 commit 9cf2421
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions contrib/pangeya
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env python3
# coding=utf-8
import sys, itertools

replacers = {
"ru": (
('а', 'с', 'о', 'р', 'е', 'х', 'у', 'А', 'В', 'Е', 'С', 'К', 'М', 'О', 'Р', 'Х'),
('a', 'c', 'o', 'p', 'e', 'x', 'y', 'A', 'B', 'E', 'C', 'K', 'M', 'O', 'P', 'X'),
),
}

def get_code_iter(code):
return itertools.cycle([int(x) for x in ''.join([ str(bin(ord(ch)))[2:] for ch in code ])])


def steganoText(text, code, lang='ru'):
code_i = get_code_iter(code)
fin = []
repl = replacers[lang]
rw = { l[0]:l[1] for l in zip(repl[0] + repl[1], repl[1]+repl[0])}
for x in text:
t = (rw[x] if next(code_i) else x) if x in rw.keys() else x
if t != x:
print (t, x)
else:
print (x)
return ''.join(fin)

def main(args):
code = ' '.join(args) if args else 'bobuk'
block = sys.stdin.read()
sys.stdout.write(steganoText(block, code))

if __name__ == '__main__':
main(sys.argv[1:])

0 comments on commit 9cf2421

Please sign in to comment.