cipher_ltk2118.cipher_func

Module Contents

Functions

cipher(text, shift, encrypt=True)

Uses a basic shift (Caesar) cipher to encrypt text input.

cipher_ltk2118.cipher_func.cipher(text, shift, encrypt=True)[source]

Uses a basic shift (Caesar) cipher to encrypt text input.

Parameters
  • text (str) – Text to be encrypted

  • shift (int) – How many positions down the alphabet should the text be shifted?

  • encrypt (bool) – Default: True If true, cipher shifts text positionally down the alphabet If false, cipher shifts text positionally up the alphabet

Returns

new_text – Encrypted (or decrypted) text

Return type

str

Examples

>>> cipher("I have the best words", 3)
'L kdyh wkh ehvw zrugv'
>>> cipher("L kdyh wkh ehvw zrugv", 3, encrypt=False)
'I have the best words'