07.07.2023 Views

Implementing-cryptography-using-python

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 6 ■ Using Cryptography with Images 191

print('Now we will try the wronge secret.\n')

key = "AnotherKey"

crypto_steganography = CryptoSteganography(key)

secret = crypto_steganography.retrieve(modfile)

print('The secret message is: {} \n'.format(secret))

The preceding code will hide a quote from George Washington in an image

named ch6_secret_image.png. I converted the original file for this chapter to

a PNG file so that we could examine the change in file size. The original file in

this case does not need to be in a PNG format, but it makes it easier to compare

the original with the modified version. Many times, when I have hidden data

in pictures, the picture size has increased, but as you will see in Figure 6.12,

the original image was 87 KB and the image with the hidden message is only

75 KB. You are not able to guess which image has the secret hidden inside just

by examining the file sizes.

Figure 6.12: Steganography example

Additionally, you will notice that without the proper key, the secret message

is not revealed. So, the next question is, how can you determine if there is

hidden data inside an image? A number of free tools are available online that

you can use to embed and extract data from images. One tool that I have used

several times is Invisible Secrets. Now, we will explore a more complex setup

with binary data.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!