Book Image

Python Web Penetration Testing Cookbook

By : Benjamin May, Cameron Buchanan, Andrew Mabbitt, Dave Mound, Terry Ip
Book Image

Python Web Penetration Testing Cookbook

By: Benjamin May, Cameron Buchanan, Andrew Mabbitt, Dave Mound, Terry Ip

Overview of this book

Table of Contents (16 chapters)
Python Web Penetration Testing Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Cracking the Atbash cipher


The Atbash cipher is a simple cipher that uses opposite values in the alphabet to transform words. For example, A is equal to Z and C is equal to X.

Getting ready

For this, we will only need the string module.

How to do it…

Since the Atbash cipher works by using the opposite value of a character in the alphabet, we can create a maketrans feature to substitute characters:

import string
input = raw_input("Please enter the value you would like to Atbash Cipher: ")
transform = string.maketrans(
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
"ZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcba")
final = string.translate(input, transform)
print final

How it works…

After importing the correct module, we request the input from the user for the value they would like encipher into the Atbash cipher:

import string
input = raw_input("Please enter the value you would like to Atbash Ciper: ")

Next, we create the maketrans feature to be used. We do this by listing the first...