1

Hide Your Data Into An Image Using Python

The Python Way :-
It is possible to hide some data into an image as demonstrated in my previous post. In this post we are going to accomplish just that but by using Python. Now you must be thinking if we can do it using command prompt in Windows then why should we bother with python, so the answer to that question is Because We Can..!!
hidden-data-behind-image


Behind The Scene :-
Before i tell you how to hide the data into an image, let’s discuss what is really happening in the background :-
The process opens each file at it’s binary state and merges them into one. To view the image you can open it simply and if you want to view the hidden data open it with any archiver software like 7zip as the files must be first archived before merging into the image.

Don’t Miss :- Password Protect Any Folder In Windows (No Software)

Requirement :-

  • Python Compiler
  • Text Editor

The Process :-
Type the following lines in a text file and save it with .py extension :

  • image = open(“image.jpg”, “ab”)
  • archive = open(“file.zip”,”rb”)
  • image.write(“n”+archive.read())
  • image.close()
  • archive.close()

Here image.jpg is the image behind which the data will be hidden and file.zip is the file which contains the data to be hidden.
So, with just 5 lines of code we can easily hide our data from the eyes of an unsuspecting user. Note that it doesn’t encrypt the data in any way, a user with some know-how could still find the information that is hidden.

If you feel the need to split the files again you can create and run this python script same as above :

  • import os
  • imgsize = os.stat(“image.jpg”).st_size
  • image = open(“image.jpg”, “ab”)
  • archsize = os.stat(“file.zip”).st_size
  • archive = open(“file.zip”,”rb”)
  • image.write(“n”+archive.read())
  • image.close()
  • archive.close()
  • narchive = open(“file2.zip”, “wb”)
  • old = open(“image.jpg”, “rb”)
  • oldr = old.read()
  • data = oldr[-archsize:]
  • narchive.write(data)
  • narchive.close()
  • old.close()

Just run this script and your file will be splitted in no time.

Have an interesting point to add, do let us know in the comments section below.

Enjoy..!!

See Also :- Create An Almighty Folder In Windows

Aditya Singh

I am a part-time blogger from U.P, India. I like to write about Computers ( Programming, Hacking, Softwares etc.) on this blog. I'm a rookie at blogging and just started it with a view to share tips and tricks on technology. This blog was created to share the things i learned or is learning.

One Comment

  1. I must say i liked examining your personal write-up. You come to some very good points I got just looking for this information for a time. Soon after half a dozen hrs involving ongoing Googleing, last but not least I bought the idea within your internet site. My spouse and i ponder precisely often the Google’s concern that doesn’t get ranking this sort of beneficial internet sites more close to the best. Normally the very best websites contain rubbish.

Leave a Reply

Your email address will not be published. Required fields are marked *