Advertisement
khbr

unhideMesage_textstego1.py

Nov 19th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.87 KB | None | 0 0
  1. import sys
  2. import os
  3.  
  4. def main():
  5.     if len(sys.argv) != 2:
  6.         print 'Usage: python %s <input-file>' % sys.argv[0]
  7.         exit(1)
  8.        
  9.     input_file   = sys.argv[1]
  10.    
  11.     if not os.path.exists(input_file):
  12.         print 'File "%s" does not exist' % input_file
  13.         exit(1)
  14.        
  15.     with open(input_file) as f:
  16.         container_with_secret = f.read()
  17.        
  18.     bits = ''
  19.     space_count = 0
  20.     for c in container_with_secret:
  21.         if c == ' ':
  22.             space_count += 1
  23.            
  24.         if space_count == 2:
  25.             bits += '1'
  26.             space_count = 0
  27.             continue
  28.            
  29.         if c != ' ' and space_count == 1:
  30.             bits += '0'
  31.             space_count = 0
  32.        
  33.     print ''.join([chr(int(bits[i:i+8], 2)) for i in range(0, len(bits), 8)])
  34.    
  35.  
  36. if __name__ == '__main__':
  37.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement