ciphers.autokey

https://en.wikipedia.org/wiki/Autokey_cipher An autokey cipher (also known as the autoclave cipher) is a cipher that incorporates the message (the plaintext) into the key. The key is generated from the message in some automated fashion, sometimes by selecting certain letters from the text or, more commonly, by adding a short primer key to the front of the message.

Attributes

operation

Functions

decrypt(→ str)

Decrypt a given ciphertext (string) and key (string), returning the decrypted

encrypt(→ str)

Encrypt a given plaintext (string) and key (string), returning the

Module Contents

ciphers.autokey.decrypt(ciphertext: str, key: str) str

Decrypt a given ciphertext (string) and key (string), returning the decrypted ciphertext. >>> decrypt(“jsqqs avvwo”, “coffee”) ‘hello world’ >>> decrypt(“vvjfpk wj ohvp su ddylsv”, “TheAlgorithms”) ‘coffee is good as python’ >>> decrypt(“vvjfpk wj ohvp su ddylsv”, “”) Traceback (most recent call last):

ValueError: key is empty >>> decrypt(527.26, “TheAlgorithms”) Traceback (most recent call last):

TypeError: ciphertext must be a string >>> decrypt(“”, “TheAlgorithms”) Traceback (most recent call last):

ValueError: ciphertext is empty >>> decrypt(“vvjfpk wj ohvp su ddylsv”, 2) Traceback (most recent call last):

TypeError: key must be a string

ciphers.autokey.encrypt(plaintext: str, key: str) str

Encrypt a given plaintext (string) and key (string), returning the encrypted ciphertext. >>> encrypt(“hello world”, “coffee”) ‘jsqqs avvwo’ >>> encrypt(“coffee is good as python”, “TheAlgorithms”) ‘vvjfpk wj ohvp su ddylsv’ >>> encrypt(“coffee is good as python”, 2) Traceback (most recent call last):

TypeError: key must be a string >>> encrypt(“”, “TheAlgorithms”) Traceback (most recent call last):

ValueError: plaintext is empty >>> encrypt(“coffee is good as python”, “”) Traceback (most recent call last):

ValueError: key is empty >>> encrypt(527.26, “TheAlgorithms”) Traceback (most recent call last):

TypeError: plaintext must be a string

ciphers.autokey.operation