Git Product home page Git Product logo

classicrack's Introduction

classicrack

MIT license Documentation Status

[wip ๐Ÿ› ๏ธ] A Python library for implementing and cracking classical ciphers (Atbash, Caesar, ROT13, etc.)

Supported Ciphers

Documentation

Full Docs: https://classicrack.readthedocs.io/en/latest/

Installation

pip install -r requirements.txt

Cryptanalysis

For cracking, cipher implementations have a crack() method. Implementations of some ciphers, such as ROT-13 and Atbash do not have it, since the decode() method already performs the same task.

So far, classicrack can only perform cryptanalysis on ciphers with keyspace weaknesses (e.g. Affine, Caesar). Implementations for other ciphers such as Vigenere might be added soon.

Ciphers

Affine

Example

from classicrack.ciphers import Affine

af = Affine()

# encode (plaintext, a, b)
af.encode('cheemsburger', 5, 8)
# decode (ciphertext, a, b)
af.decode('srccqunepmcp', 5, 8)
# crack (ciphertext)
af.crack('srccqunepmcp')

encode (pt, a, b): encrypts the input plaintext using Affine

  • pt: the input plaintext
  • a: a slope value, which must be a positive integer coprime with 26
  • b: an intercept value, which can take any positive integer

decode (ct, a, b): decrypts an input ciphertext using Affine

  • ct: the input ciphertext
  • a: a slope value, which must be a positive integer coprime with 26
  • b: an intercept value, which can take any positive integer

crack (ct): cracks an input Affine ciphertext

  • ct: the input ciphertext

Atbash

Example

from classicrack.ciphers import Atbash

ab = Atbash()

# encode
ab.encode('zebras')
# decode
ab.decode('avyizh')

encode (pt): encrypts the input plaintext using Atbash

  • pt: the input plaintext

decode (ct): decrypts a ciphertext using Atbash

  • ct: the input ciphertext

Caesar

Example

from classicrack.ciphers import Caesar

cs = Caesar()

# encode
cs.encode('cheemsburger', 13)
# decode
cs.decode('purrzfohetre', 13)
# crack
cs.crack('purrzfohetre')

encode (pt, shift): encrypts the input plaintext with Caesar's Cipher

  • pt: the input plaintext
  • shift: a shift value, which can be any positive integer

decode (ct, a, b): decrypts a ciphertext encrypted with Caesar's Cipher

  • ct: the input ciphertext
  • shift: a shift value, which can be any positive integer

crack (ct): cracks an input Caesar ciphertext

  • ct: the input ciphertext

ROT13

Example

from classicrack.ciphers import ROT13

rot = ROT13()

# encode
rot.encode('cheemsburger')
# decode
rot.decode('purrzfohetre')

encode (pt): encrypts the input plaintext with ROT-13

  • pt: the input plaintext

decode (ct): decrypts a ciphertext encrypted with ROT-13

  • ct: the input ciphertext

License

MIT License

classicrack's People

Contributors

starkfire avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.