Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Hands-On Cryptography with Python

You're reading from   Hands-On Cryptography with Python Leverage the power of Python to encrypt and decrypt data

Arrow left icon
Product type Paperback
Published in Jun 2018
Publisher Packt
ISBN-13 9781789534443
Length 100 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Samuel Bowne Samuel Bowne
Author Profile Icon Samuel Bowne
Samuel Bowne
Arrow right icon
View More author details
Toc

Challenge 2 – base64

After a base64 review, we'll perform an example to show you how to decode some obfuscated text, and then we have one simple and one hard challenge for you.

Here is the base64 review:

base64 encoding text makes it longer. Here's the sample text to decode:

U2FtcGxliHRleHQ=

It decodes into the string sample text. Let's take a look at that.

Refer to the following steps:

  1. If you run python in immediate mode, it will do four simple jobs:
$ python
  1. So, if we take ABC and encode it with base64, we get this string:
>>> "ABC".encode("base64")
'QUJD\n'
  1. If we decode that with base64, we get back to the original text:
>>> "QUJD".decode("base64")
'ABC'
  1. So, the challenge text is as follows, and if you decode it, you get the string sample text:
>>> "U2FtcGxliHRleHQ=".decode("base64")
'Sample text'
  1. So, that will do for simple case; your first challenge looks like that:
Decode this: VGhpcyBpcyB0b28gZWFzeQ==
  1. Here's a long string to decode for your longer challenge:
Decode this:
VWtkc2EwbEliSFprVTJeFl6SlZaMWxUUW5OaU1qbDNVSGM5UFFvPQo=

This long string is so long because it's been encoded by base64 not just once but several times. So, you'll have to try decoding it until it turns into something readable. In the next section, we'll have Challenge 3 – XOR.

You have been reading a chapter from
Hands-On Cryptography with Python
Published in: Jun 2018
Publisher: Packt
ISBN-13: 9781789534443
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
Banner background image