Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- print (os.getcwd())
- os.chdir("/storage/emulated/0/PY")
- print (os.getcwd())
- def encrypt(key, text):
- result = ""
- for c in text:
- if ord(c) == 32:
- result += " "
- else:
- result += chr(ord(c) + key)
- print (result)
- return result
- def write(filename, text):
- f = open(filename, "w")
- c = f.write(text)
- print (c)
- f.close()
- def read(filename):
- f = open(filename, "r")
- c = f.read()
- f.close()
- return c
- def decrypt(key, text):
- result = ""
- if key.isdigit():
- key = int(key)
- else:
- print ("Key must be integer.")
- return None
- for c in text:
- if ord(c) == 32:
- result += " "
- else:
- result += chr(int(ord(c) - key))
- print (result)
- write(input("Input file name to encrypt. "), encrypt(5, read("h.txt"))
- #encrypt(5, read(input("Input file name to encrypt. ")))
- decrypt(input("Input key number. "), read("h.txt"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement