Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 34 lines (27 sloc) 926 Bytes
#!/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])}
for x in text:
t = (rw[x] if next(code_i) else x) if x in rw.keys() else x
fin.append(t)
return ''.join(fin)
def main(args):
code = ' '.join(args) if args else 'bobuk'
block = sys.stdin.read()
text = steganoText(block, code)
sys.stdout.write(text)
if __name__ == '__main__':
main(sys.argv[1:])
Jump to Line
Something went wrong with that request. Please try again.