Skip to main content

A Python package and command line script for encoding, decoding and cracking messages with the Caesar Shift Cipher.

https://travis-ci.org/RobSpectre/Caesar-Cipher.svg?branch=master https://coveralls.io/repos/RobSpectre/Caesar-Cipher/badge.png?branch=master

Table of Contents

Features

  • Encoding

  • Decoding

  • Cracking (decoding ciphertext without known offset)

  • Arbitrary cipher offsets

  • Command Line Interface

  • Test suite

  • Support for both Python 2 and 3

  • PEP8. Praise the Dark Lord

Installation

The latest version can be installed via pip.

$ pip install caesarcipher

If that doesn’t work, give easy_install a try:

$ easy_install caesarcipher

Usage

Command Line

Encoding a message:

$ caesarcipher --encode "This is a message I want to encode."

Encoding a message with a specific offset:

$ caesarcipher --offset 14 --encode "This is a message I want to encode."

Decoding a ciphertext with a specific offset:

$ caesarcipher --offset 14 --decode "W kobh hc sbqcrs hvwg ghfwbu."

Cracking a ciphertext without knowing the offset:

$ caesarcipher --crack "W kobh hc sbqcrs hvwg ghfwbu."

Library

Encoding a message:

>>> from caesarcipher import CaesarCipher
>>> cipher = CaesarCipher('I want to encode this string')
>>> cipher.encoded
'W kobh hc sbqcrs hvwg ghfwbu.'

Encoding a message with a specific offset:

>>> from caesarcipher import CaesarCipher
>>> cipher = CaesarCipher('I want to encode this string.',
...     offset=14)
>>> cipher.encoded
'W kobh hc sbqcrs hvwg ghfwbu.'

Decoding a ciphertext with a specific offset:

>>> from caesarcipher import CaesarCipher
>>> cipher = CaesarCipher('W kobh hc sbqcrs hvwg ghfwbu.',
...    offset=14)
>>> cipher.decoded
'I want to encode this string.'

Cracking a ciphertext without knowing the offset:

>>> from caesarcipher import CaesarCipher
>>> cipher = CaesarCipher('W kobh hc sbqcrs hvwg ghfwbu.')
>>> cipher.cracked
'I want to encode this string.'

Development

Hacking

To hack on the project, clone the GitHub repo:

$ git clone https://github.com/RobSpectre/Caesar-Cipher.git

Then install in a virtualenv.

$ pip install -e ./

Tests

The project uses Nose for tests. Simply run from the project root.

$ nosetests -v

Go ahead and check on coverage and PEP8 while you’re at it!

$ nosetests -v --with-coverage --with-tissue

Meta

  • Written by Rob Spectre

  • Used for Hacker Olympics London 2014

  • Released under MIT License

  • Software is as is - no warranty expressed or implied.

  • The Caesar Shift Cipher is known to be ridiculously easy to crack, as evidenced by this very package. Do not confuse with actual cryptography or use in anything that is important - it’s just a fun math problem for a sunny vacation afternoon.

Release files for caesarcipher 1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for caesarcipher 1.0
File Size Uploaded
caesarcipher-1.0.tar.gz 10.1 kB Details

Release files / caesarcipher-1.0.tar.gz

Download URL caesarcipher-1.0.tar.gz
Size 10.1 kB
Tags Source
SHA-256 checksum
How to use checksums
19203849fa0309fc356cac18a138726ac2463af665cb5cc20174cbae54c4b245
BLAKE2b-256 checksum
How to use checksums
fb5175d0cb5a391239b536869e8750e76f12df0abf7e99eccb8299d694463854
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.0 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page