Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def enc(sys):
- A1 = sys // 1000
- A2 = (sys // 100) % 10
- A3 = (sys // 10) % 10
- A4 = (sys // 1) % 10
- A1 += 7
- A1 = A1 % 10
- A2 += 7
- A2 = A2 % 10
- A3 += 7
- A3 = A3 % 10
- A4 += 7
- A4 = A4 % 10
- res = 0
- res += A3 * 1000
- res += A4 * 100
- res += A1 * 10
- res += A2
- #str(A3)+str(A4)+str(A1)+str(A2)
- res = print(A3,A4,A1,A2)
- return res #if i make it become int , 0 will not shown
- def dec(sys):
- A1 = sys // 1000
- A2 = (sys // 100) % 10
- A3 = (sys // 10) % 10
- A4 = (sys // 1) % 10
- A1 = A1 % 10
- A1 -= 7
- A2 = A2 % 10
- A2 -= 7
- A3 = A3 % 10
- A3 -= 7
- A4 = A4 % 10
- A4 -= 7
- #checked the value
- if(A1<0):
- A1 += 10
- if(A2<0):
- A2 += 10
- if(A3<0):
- A3 += 10
- if(A4<0):
- A4 += 10
- res = 0
- res += A3 * 1000
- res += A4 * 100
- res += A1 * 10
- res += A2
- res = print(A3,A4,A1,A2)
- return res
- #print(enc(1234))
- #print(dec(enc(1234)))
- def main():
- sys = 1
- while sys!=3:
- print("=======MENU=======")
- print("1. Encrypt message")
- print("2. Decrypt message")
- print("3. Quit Program")
- ch = eval(input("please choose number 1, 2 or 3 : "))
- sys = eval(input("input the number in 4 digit : "))
- if ch == 1 :
- enc(sys)
- elif ch== 2:
- dec(sys)
- elif ch == 3:
- exit
- else :
- print("number is not valid")
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement