Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Python for Secret Agents

You're reading from  Python for Secret Agents

Product type Book
Published in Aug 2014
Publisher
ISBN-13 9781783980420
Pages 216 pages
Edition 1st Edition
Languages
Author (1):
Steven F. Lott Steven F. Lott
Author Profile Icon Steven F. Lott
Steven F. Lott
Toc

Solving problems – encrypting a message


For proper encryption, the PyCrypto package can be used, which can be downloaded from https://www.dlitz.net/software/pycrypto/. As with Pillow, this is a hefty download.

As we saw in Chapter 1, Our Espionage Toolkit, a poor choice of key will render any encryption scheme essentially worthless. If we encrypt a file using a single-word key that's available in a readily available corpus of words, we haven't really made our data very secure at all. A brute-force attack will break the encryption.

We can combine steganography with the creation of a ZipFile archive to embed a message in an image in a ZIP file. As a ZIP file can have a comment string, we can include an HMAC signature as the comment for the ZIP archive.

Ideally, we'd use the ZIP encryption. However, the Python ZipFile library doesn't create encrypted ZIP files. It only reads encrypted files.

We're going to define a function that looks like this:

def package( text, image_source, key_hmac, filename...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime