• Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
AnonyViet - English Version
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
No Result
View All Result
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
No Result
View All Result
AnonyViet - English Version
No Result
View All Result

How to create secret messages in pictures using Python

AnonyViet by AnonyViet
January 31, 2023
in Tips
0

Today, I will show you how to apply coding skills, by hiding a password or secret message in a photo with Python. Steganography is a technique that has been used for quite some time. Since World War II, it has been used extensively as a means of communication between allies and to prevent information held by enemies from being revealed. I will show you how to do this using two different techniques, one involving the secret key and the other not.

Join the channel Telegram of the AnonyViet 👉 Link 👈

How to create secret messages in pictures using Python

Request

You install Python and then continue to install the 2 libraries below.

Setting

pip install steganocryptopy
pip install stegano

Note: If you use Linux, change pip to pip3.

How to send secret messages in photos without a key

I will hide the text in the image without any encryption key, so the recipient of the image can decrypt and get the hidden text very easily.

Advantage

The advantage of this is that it’s very simple so you won’t have to deal with any annoying problems.

Defect

Anyone can decrypt as long as they use the same library that you used during encryption.

Syntax

from stegano import lsb
secret = lsb.hide(path_to_img, secret_msg)
secret.save(ecrypted_img_name)

You must have a sample image in your project folder to hide the message, next we have to provide the path to the prepared image.

Eg

>>> from stegano import lsb
>>> secret = lsb.hide("sample.png", "Python is dangerous be careful")
>>> secret.save("sample_secret.png")

Note: Since the sample.png file is in the same directory as the .py executable, it is enough to just write the image file name. If the image file is different from the directory, you need to write the full path.

Now if you look in the project folder you will notice there is a new image with the name sample_secret.png. At a glance or look closely, you won’t know there is a hidden message in there, right?

Decryption

Make sure the image with hidden text is in your project folder.

Syntax

>>> from stegano import lsb
>>>lsb.reveal(path_to_an_image)

Eg

>>> from stegano import lsb
>>>lsb.reveal('sample_secret.png')
'Python is dangerous be careful'

That’s it, now we will dive into how to hide text in images with secret key.

How to hide text in images with Secret Key

I will hide the secret text along with an encryption key to decrypt it. Therefore, only the person with the key can decrypt it.

Advantage

It is very secure because only those who have the key can decrypt it.

Defect

When the encryption key is lost, the decryption process will be a bit complicated.

Syntax

>>>from steganocryptopy.steganography import Steganography
>>> Steganography.generate_key(path_to_key)
>>> encrypted = Steganography.encrypt(path_to_key, path_to_img, path_to_secretfile)
>>> encrypted.save(encrypted_imgname)

Eg

Suppose I have a file containing a key named keya file containing hidden messages named classified.us and the image is called sample.png.

>>>from steganocryptopy.steganography import Steganography
>>> Steganography.generate_key("key")
>>> encrypted = Steganography.encrypt("key","sample.png",  "classified.us")
>>> encrypted.save("Secret.png")

Now when you run the above code you will see a new image on your project folder named Secret.png.

Decryption

To decode the image you will need the file containing key and your encrypted images.

Syntax

>>> from steganocryptopy.steganography import Steganography
>>> Steganography.decrypt(path_to_key, path_to_image)

Eg

>>> from steganocryptopy.steganography import Steganography
>>> Steganography.decrypt("key", "Secret_img.png")
'Life is short you need Python\n'

Congratulations, you just learned how to hide secret messages in pictures, Now don’t be afraid to share the message with your friends.

The article achieved: 5/5 – (100 votes)

Tags: createmessagespicturesPythonsecret
Previous Post

Download Gigapixel AI 4.4.5 Full – Sharpen broken or blurred images

Next Post

Download Check Flash – USB quality check software

AnonyViet

AnonyViet

Related Posts

How to change the default font on Windows 10
Tips

How to change the default font on Windows 10

April 13, 2026
5 tips for using a Browser to replace an App (helps save RAM, time and money)
Tips

5 tips for using a Browser to replace an App (helps save RAM, time and money)

April 13, 2026
How to make funny MeMe photos without Photoshop within 10 seconds
Tips

How to make funny MeMe photos without Photoshop within 10 seconds

April 11, 2026
How to quickly design your own Logo without Photoshop
Tips

How to quickly design your own Logo without Photoshop

April 10, 2026
How to convert Website into App on Windows
Tips

How to convert Website into App on Windows

April 9, 2026
Instructions for getting 3 months of Adobe Express Pro for free
Tips

Instructions for getting 3 months of Adobe Express Pro for free

April 9, 2026
Next Post
Download Check Flash – USB quality check software

Download Check Flash - USB quality check software

0 0 votes
Article Rating
Subscribe
Login
Notify of
guest

guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Recent News

How to add Watermark to Google Docs to protect copyright

How to add Watermark to Google Docs to protect copyright

April 19, 2026
How to intercept traffic using Burp Suite to analyze HTTP/HTTPS

How to intercept traffic using Burp Suite to analyze HTTP/HTTPS

April 18, 2026
How to avoid Adblock detection on Youtube with 4 good tips

How to avoid Adblock detection on Youtube with 4 good tips

April 17, 2026
How to transfer ChatGPT data to Claude is extremely simple

How to transfer ChatGPT data to Claude is extremely simple

April 16, 2026
How to add Watermark to Google Docs to protect copyright

How to add Watermark to Google Docs to protect copyright

April 19, 2026
How to intercept traffic using Burp Suite to analyze HTTP/HTTPS

How to intercept traffic using Burp Suite to analyze HTTP/HTTPS

April 18, 2026
How to avoid Adblock detection on Youtube with 4 good tips

How to avoid Adblock detection on Youtube with 4 good tips

April 17, 2026
AnonyViet - English Version

AnonyViet

AnonyViet is a website share knowledge that you have never learned in school!

We are ready to welcome your comments, as well as your articles sent to AnonyViet.

Follow Us

Contact:

Email: anonyviet.com[@]gmail.com

Main Website: https://anonyviet.com

Recent News

How to add Watermark to Google Docs to protect copyright

How to add Watermark to Google Docs to protect copyright

April 19, 2026
How to intercept traffic using Burp Suite to analyze HTTP/HTTPS

How to intercept traffic using Burp Suite to analyze HTTP/HTTPS

April 18, 2026
No Result
View All Result
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office

wpDiscuz
0
0
Would love your thoughts, please comment.x
()
x
| Reply