#! /usr/bin/python import os import sys import md5 import cStringIO as StringIO plaintext = sys.stdin inf = os.fdopen(3) outf = sys.stdout for i in range(3): outf.write(inf.readline()) # Set the low-order bits in output file i = 0 while True: c = plaintext.read(1) if c: c = ord(c) else: c = 0 img_bytes = inf.read(8) if not img_bytes: break if len(img_bytes) < 8: outf.write(img_bytes) break for j in range(8): bit = 7 - j img_byte = ord(img_bytes[j]) & 0xFE noise_bit = (c & (1<> bit out_byte = img_byte | noise_bit outf.write(chr(out_byte))