Advertisement
obernardovieira

(CGI) Encode data file (base64)

Jan 14th, 2015
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.39 KB | None | 0 0
  1. #!C:\Python34\python.exe
  2.  
  3. import cgi, cgitb, sys
  4. import base64
  5.  
  6. cgitb.enable()
  7. print("Content-type: text/html")
  8. print()
  9.  
  10.  
  11. myfile = open("original.txt","rb")
  12. text = myfile.read()
  13. myfile.close()
  14.  
  15. print('Original:',text,'<br/>')
  16. encoded = base64.b85encode(text)
  17.  
  18. secondfile  = open("encoded.txt","wb")
  19. secondfile.write(encoded)
  20. secondfile.close()
  21.  
  22. print('Encoded:',encoded,'<br/>')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement