-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsricrypt.py
47 lines (47 loc) · 909 Bytes
/
sricrypt.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python
import math
new_string=[]
dec=[]
def substitute(ch):
temp = ord(ch)
temp=temp-96
temp=temp+5
val = int(math.fmod(temp,26))
val=val+96
oc=chr(val)
new_string.append(oc)
def resub(ch2):
temp=ord(ch2)
temp=temp-96
temp=temp-5
val=int(math.fmod(temp,26))
val=val+96
oc2=chr(val)
dec.append(oc2)
def sri_crypt(message):
message=list(message)
for char in message:
substitute(char)
def sri_decrypt(message):
message=list(message)
for char in message:
resub(char)
def custom_enc(message):
sri_crypt(message)
round1=''.join(new_string)
sri_crypt(round1)
round2=''.join(new_string)
sri_crypt(round2)
round3=''.join(new_string)
l=len(round3)
m=len(message)
return round3[:m]
def custom_dec(a):
sri_decrypt(a)
dec_value=''.join(dec)
sri_decrypt(dec_value)
dec_value2=''.join(dec)
sri_decrypt(dec_value2)
dec_value3=''.join(dec)
m=len(a)
return dec_value3[:m]