python基于base64加密解密文件

#! /usr/bin/python
# encoding : utf-8

import base64

def encry(cnf_org):
    f_org = open(cnf_org,'r')
    content = f_org.read()
    content1 = content.encode(encoding='utf-8')
    content2 = base64.b64encode(content1)
    f_org.close()
    with open(cnf_org,'wb+') as f_org:
        f_org.write(content2)

def deci(cnf_now):
    f_now = open(cnf_now,'r')
    content = f_now.read()
    content1 = base64.b64decode((content))
    with open(cnf_now,'wb+') as f_now:
        f_now.write(content1)

if __name__ == '__main__':
    f_org ='E:/applog/log.cnf'
    encry(f_org)

展开阅读全文

没有更多推荐了,返回首页