windows 加密隐私文件方式
2017-01-12 17:24
323 查看
有时候移动硬盘存点小电影,老怕别人借过去发现。所以要加密一下
用隐藏文件的方式。加上对文件后缀名的加密
用一个脚本,输入密码输入正确才可以自动显示文件。
主要用cmd的 attrib 命令
两个比较重要的参数 h 和s
隐藏时cmd命令为 attrib +h +s 文件
显示时cmd命令为 attrib -h -s 文件
python脚本代码如下
然后再使用pyinstaller 把脚本转换成exe文件。放到目录下就可以了。
pyinstaller 打包很方便。直接pyinstaller -F -c pass.py
打包以后执行界面是这样的
输入密码后就可以解锁成功。然后就会显示出隐藏的文件夹。
用隐藏文件的方式。加上对文件后缀名的加密
用一个脚本,输入密码输入正确才可以自动显示文件。
主要用cmd的 attrib 命令
两个比较重要的参数 h 和s
隐藏时cmd命令为 attrib +h +s 文件
显示时cmd命令为 attrib -h -s 文件
python脚本代码如下
# -*- coding: utf-8 -*- import os class test(): def __init__(self,filename): self.filename = filename #视频文件后缀加密 def encrypt(self): for root,dirs,files in os.walk(self.filename, topdown=False): for file in files: #print(os.path.join(root, file)) name = file.split('.',1) #print name[1] if name[1] == 'mp4': #os.chdir(root) newname = str(name[0])+".liao" os.rename(os.path.join(root, file),os.path.join(root, newname)) elif name[1] == 'avi': #os.chdir(root) newname = str(name[0])+".liao1" os.rename(os.path.join(root, file),os.path.join(root, newname)) elif name[1] == 'rmvb': #os.chdir(root) newname = str(name[0])+".liao2" os.rename(os.path.join(root, file),os.path.join(root, newname)) else: pass #视频文件后缀解密 def decrypt(self): for root,dirs,files in os.walk(self.filename, topdown=False): for file in files: print(os.path.join(root, file)) name = file.split('.',1) print name[1] if name[1] == 'liao': #os.chdir(root) newname = str(name[0])+".mp4" os.rename(os.path.join(root, file),os.path.join(root, newname)) elif name[1] == 'liao1': #os.chdir(root) newname = str(name[0])+".avi" os.rename(os.path.join(root, file),os.path.join(root, newname)) elif name[1] == 'liao2': #os.chdir(root) newname = str(name[0])+".rmvb" os.rename(os.path.join(root, file),os.path.join(root, newname)) else: pass if __name__ == "__main__": filename = 'test' #隐藏文件test test(filename).encrypt() p = os.popen('attrib +s +h' + ' '+ filename) p.close() #输入密码显示文件 password = '123456' count = 1 max = 3 #设置最大尝试次数 while True: input = raw_input("请输入文件密码:") if input != password: if (max-count) == 0: print "已经超过最大尝试次数" break else: print "密码输入错误%s次,您还有%s次"%(count,max-count) count += 1 else: print "密码输入正确正在解锁" p = os.popen('attrib -s -h' +' '+ filename) p.close() test(filename).decrypt() print "解锁完成" break输入密码正确才可以显示文件夹,输入错误3次则会停止程序。
然后再使用pyinstaller 把脚本转换成exe文件。放到目录下就可以了。
pyinstaller 打包很方便。直接pyinstaller -F -c pass.py
打包以后执行界面是这样的
输入密码后就可以解锁成功。然后就会显示出隐藏的文件夹。
相关文章推荐
- Windows快捷方式文件格式解析
- Windows与Vmware下的Linux文件共享方式总结
- Windows与Vmware下的Linux文件共享方式总结
- windows EFS加密文件(夹)
- Windows快捷方式文件格式解析
- Windows与Vmware下的Linux文件共享方式总结
- Windows快捷方式文件格式详解(附代码)
- Windows与VMware下的Linux文件共享方式总结
- 【转】Windows快捷方式文件格式解析(中文)
- Windows Mobile Web方式下载文件
- Windows快捷方式文件格式解析
- 【嵌入式Linux学习七步曲之第一篇 Linux主机开发环境】虚拟机下Linux和windows的文件共享――mount方式
- 【嵌入式Linux学习七步曲之第一篇 Linux主机开发环境】虚拟机下Linux和windows的文件共享――共享方式
- Windows与VMware下的Linux文件共享方式总结
- Windows快捷方式文件格式解析
- Windows下各类文件的打开方式
- Windows与Vmware下的Linux文件共享方式总结
- 文件打开的几种方式(c/c++/Windows)
- Windows文件属性-高级-加密内容以便保护数据:EFS加密后如何 解密
- Windows Mobile Web方式下载文件