base64_2.py 390 B

12345678910
  1. def encryptFile():
  2. myFile = input("enter file to encrypt: ")
  3. file = open(myFile,"r")
  4. contents = file.read()
  5. contents = contents.encode()
  6. file = open(myFile, "w")
  7. encoded = base64.b64encode(contents)
  8. # the .decode() converts the bytes to str, taking off the b'...'
  9. file.write(str(encoded))
  10. print ("File is now encrypted... and the contents is unreadable")