Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/subbarayudu-j/TheAlgorithms-Python
/ encrypt
Function
encrypt
ciphers/caesar_cipher.py:2–9 ·
view source on GitHub ↗
(strng, key)
Source
from the content-addressed store, hash-verified
1
import
sys
2
def
encrypt(strng, key):
3
encrypted =
''
4
for
x in strng:
5
indx = (ord(x) + key) % 256
6
if
indx > 126:
7
indx = indx - 95
8
encrypted = encrypted + chr(indx)
9
return
encrypted
10
11
12
def
decrypt(strng, key):
Callers
1
main
Function · 0.85
Calls
no outgoing calls
Tested by
no test coverage detected