MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / encrypt

Function encrypt

ciphers/porta_cipher.py:41–52  ·  view source on GitHub ↗

>>> encrypt('marvin', 'jessica') 'QRACRWU'

(key: str, words: str)

Source from the content-addressed store, hash-verified

39
40
41def encrypt(key: str, words: str) -> str:
42 """
43 >>> encrypt('marvin', 'jessica')
44 'QRACRWU'
45 """
46 cipher = ""
47 count = 0
48 table = generate_table(key)
49 for char in words.upper():
50 cipher += get_opponent(table[count], char)
51 count = (count + 1) % len(table)
52 return cipher
53
54
55def decrypt(key: str, words: str) -> str:

Callers 2

decryptFunction · 0.70
porta_cipher.pyFile · 0.70

Calls 2

get_opponentFunction · 0.85
generate_tableFunction · 0.70

Tested by

no test coverage detected