项目作者: starkfire

项目描述 :
(wip 🛠️) Python library for implementing and cracking classical ciphers (Caesar, Atbash, ROT13, etc)
高级语言: Python
项目地址: git://github.com/starkfire/classicrack.git
创建时间: 2020-07-07T11:44:12Z
项目社区:https://github.com/starkfire/classicrack

开源协议:MIT License

下载


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

  1. 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

  1. from classicrack.ciphers import Affine
  2. af = Affine()
  3. # encode (plaintext, a, b)
  4. af.encode('cheemsburger', 5, 8)
  5. # decode (ciphertext, a, b)
  6. af.decode('srccqunepmcp', 5, 8)
  7. # crack (ciphertext)
  8. 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

  1. from classicrack.ciphers import Atbash
  2. ab = Atbash()
  3. # encode
  4. ab.encode('zebras')
  5. # decode
  6. 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

  1. from classicrack.ciphers import Caesar
  2. cs = Caesar()
  3. # encode
  4. cs.encode('cheemsburger', 13)
  5. # decode
  6. cs.decode('purrzfohetre', 13)
  7. # crack
  8. 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

  1. from classicrack.ciphers import ROT13
  2. rot = ROT13()
  3. # encode
  4. rot.encode('cheemsburger')
  5. # decode
  6. 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