EncodeFile(python2.7
加密
)
# -*- coding: utf8 -*-
import base64
import sys
reload(sys)
sys.setdefaultencoding('utf8')
inFile=sys.argv[1]
try:
fin = open(inFile, "rb")
fout = open(inFile+".txt", "w")
base64.encode(fin, fout)
pass
except Exception, e:
print u"
文件打开失败!
".encode("GBK")
finally:
fin.close()
fout.close()
print u"
编码成功!
".encode("GBK")
pass
DecodeFile(python2.7
解密
)
# -*- coding: utf8 -*-
import base64
import sys
reload(sys)
sys.setdefaultencoding('utf8')
inFile=sys.argv[1]
try:
fin = open(inFile, "rb")
fout = open(inFile.replace(".txt", ""), "wb")
base64.decode(fin, fout)
pass
except Exception, e:
print u"
文件打开失败!
".encode("GBK")
finally:
fin.close()
fout.close()
print u"
解码成功!
".encode("GBK")
pass