MCPcopy 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

1import sys
2def 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
12def decrypt(strng, key):

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected