Welcome to pythoncrypt’s documentation!

Indices and tables

Caesar cipher

Module for Caesar cipher algorithms

caesar.brute_force_decryption(message: str, initial_shift: int = 1, final_shift: int = 25, key: str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')

This function returns all shifts decryption between 1 and 25.

Parameters
  • message – message to be decrypted

  • initial_shift – Initial attempt shift

  • final_shift – Final attempt shift

  • key – key used for decryption

Returns

list of decrypted messages

caesar.decrypt(message: str, shift: int = 3, key: str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ') → str

This function decodes encrypted message in caesar’s shift way.

Parameters
  • message – str. Message to be decrypted

  • shift – int. Shift to be used

  • key – str. Key used for decryption

Returns

message decrypted: str

caesar.encrypt(message: str, shift: int = 3, key: str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ') → str

This function requires a string that will be encrypted in caesar’s shift way.

Parameters
  • message – str. Message to be encrypted

  • shift – int. Shift to be used

  • key – str. Key for encryption

Returns

message encrypted: str

Rail fence cipher

Module for rail fence cipher. In the rail fence cipher, the plain text is written downwards and diagonally on successive “rails” of an imaginary fence, then moving up when the bottom rail is reached. When the top rail is reached, the message is written downwards again until the whole plaintext is written out. The message is then read off in rows.

rail_fence.brute_force(message)

This function uses brute force rail fence to break decryption. It starts from 2 rows and keep rise until reach the length of the message.

Parameters

message – message to be decrypted

Returns

list of possibles messages decrypted

rail_fence.decrypt(message: str, rail: int) → str

This function decodes encrypted message in rail fence way.

Parameters
  • message – message to be decoded

  • rail – number of rails used to encrypt message

Returns

message decrypted

rail_fence.encrypt(message: str, rails: int = 2, no_spaces: bool = True, uppercase: bool = True) → str

Function to encrypt with rail fence cipher.

Parameters
  • message – message to be encrypted

  • rails – number of rails to be used

  • no_spaces – remove whitespaces to difficult decryption

  • uppercase – transform to uppercase to difficult decryption

Returns

encrypted message

Trevanion cipher

This null cipher uses every nth letter after a punctuation mark to encode message

trevanion.decrypt(message: str, shift: int = 3) → str

Decryption requires to know of the shift N used. To find the plain text it is necessary to browse the text in search of the signs of punctuation. After each one, count a number of characters (N) to find a new letter of the plaintext.

Parameters
  • message – message to be decrypted

  • shift – letter count after punctuation mark

Returns

message decrypted

trevanion.encrypt(message: str, shift: int = 3) → str

Encryption involves taking a text and be pay attention to position of the punctuation so that after each sign, after counting a number of letters (eg 3 letters) a letter from the hidden message is found.

Parameters
  • message – message to be encrypted

  • shift – letter count after punctuation mark

Returns

message decrypted