将OpenMe.mp3文件中的内容加密,保存为新文件 | 第028讲:文件:因为懂你,所以永恒
# 加密def enctry(keys):
key = 'JCcaZA6n9J&nWP1macAxAP$yt_f!pYits36nzhbWXinKwtXbzC*2f8r&Z5H_Yj4%9tSbRYAP$yt_f!pYits36nzhbWXinKZ5H_Yj'
encry_str = ""
for i,j in zip(keys,key):
temp = str(ord(i)+ord(j))+'_' # 加密字符 = 字符的Unicode码 + 秘钥的Unicode码
encry_str = encry_str + temp
return encry_str
# 解密
def dectry(keys):
key = 'JCcaZA6n9J&nWP1macAxAP$yt_f!pYits36nzhbWXinKwtXbzC*2f8r&Z5H_Yj4%9tSbRYAP$yt_f!pYits36nzhbWXinKZ5H_Yj'
dec_str = ""
for i,j in zip(keys.split("_")[:-1],key):
temp = chr(int(i) - ord(j)) # 解密字符 = (加密Unicode码字符 - 秘钥字符的Unicode码)的单字节字符
dec_str = dec_str+temp
return dec_str
aa = open('替换为你的目录路径!!!!!\\OpenMe.mp3')
bb = open('替换为你的目录路径!!!!!\\OpenMe.dhl', 'x')
enc_str = enctry(aa.read())
bb.write(enc_str)
aa.close()
bb.close()
{:5_106:}
页:
[1]