Skip to content

Commit c2a2e3c

Browse files
committed
added encrypt and decrypt function
1 parent 2d95659 commit c2a2e3c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

app.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
def encrypt(text, key=0):
2+
if not isinstance(text, str):
3+
raise TypeError("{} should be a type string".format(text))
4+
if not isinstance(key, int):
5+
raise TypeError("{} should be of type int".format(key))
6+
return "".join([chr(ord(something) + key) for something in text])
7+
8+
9+
def decrypt(text, key=0):
10+
if not isinstance(text, str):
11+
raise TypeError("{} should be a type string".format(text))
12+
if not isinstance(key, int):
13+
raise TypeError("{} should be of type int".format(key))
14+
return "".join([chr(ord(something) - key) for something in text])

0 commit comments

Comments
 (0)