Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import os
- def to_binary_string(s):
- binary_s = ''
- for c in s:
- binary_s += '{:08b}'.format(ord(c))
- return binary_s
- def main():
- if len(sys.argv) != 4:
- print 'Usage: python %s <input-file> <message> <output-file>' % sys.argv[0]
- exit(1)
- input_file = sys.argv[1]
- message = sys.argv[2]
- output_file = sys.argv[3]
- if not os.path.exists(input_file):
- print 'File "%s" does not exist' % input_file
- exit(1)
- message_hex = message.encode('hex')
- with open(input_file) as f:
- container = f.read()
- lines = container.split('\n')
- for i in range(len(message_hex)):
- lines[i] += ' ' * int(message_hex[i], 16)
- with open(output_file, 'w') as f:
- f.write('\n'.join(lines))
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement