win10 中能否给文件夹设置密码?

关注者
670
被浏览
2,935,799

36 个回答

更新:【请谨慎使用!】因为代码只在我自己的几台电脑上测试过,评论区发现大家在使用过程中可能会遇到各种问题,但我无法复现所以也不好debug,因此希望大家谨慎使用,比如在一个测试路径只放几个不同类型的测试文件,先试试,试成功了再考虑用来隐藏自己的学习资料。祝大家学习进步,学习强国!


感觉自己明白题主的意思!我硬盘某个角落也经常会存放一些学习资料,不想哪天过海关时被境外敌对势力窃取,或者被思想觉悟不高的朋友偶然发现,引起不必要的疑惑。(答主:才不一样!)

所以当我们在想「能否给文件夹设置密码」时,我们需要的不是「用系统自带加密就可以」这样的鸡肋答案,因为系统加密只能阻止其他账户访问,登录账户如果是自己的就完犊子了。

同样,也不需要「为什么要加密,登录账户就该每人一个分开使用」这样的站着说话不腰疼。要是哪天女朋友用你本子,你说稍等,我先给你切换成访客账户,那你以后和朋友谈笑风生说起这段,不免两眼泛泪,止不住地拍打轮椅扶手。

用BitLocker,第三方软件,或压缩文件时设置密码不失为一种选择,但除密码一旦丢失极难找回之外,加密文件量大时需要占用大量时间与计算资源,本子的话还会影响续航。现在学习任务日趋繁重,一套教程就几十上百G,等加密完黄花大姑娘都凉了。因此对这类加密需求而言,第三方软件恐怕并非最优解。

归根结底,我们不是真的想用顶级安全算法把所有文件都五花大绑,搞得自己用起来也麻烦。我们只不希望一般人随便翻两下就能搞出个大新闻。当然,对于一些来之不易的珍贵学习资料,依然值得用两三层密码去保护她。

我之前一直用的是这段广为流传的江湖代码去隐藏文件夹。基本思路和高赞一样,都是利用文件标识符进行伪装。高赞答主还专门开发了软件,解决方案近乎完美。但唯一阻止我使用的痒点在于,我不太喜欢往右键菜单里塞奇怪的选项。然而受这两位仁兄启发,我想,何不自己动手,天下我有。于是试着写了个Windows脚本文件,试用两天感觉良好,特来回馈社区。

无图言dio

使用效果如下

不好意思走错片场,使用效果如下

因为预想需求有针对不同场景与不同假想敌选择相应安全等级,此脚本主要有三种办法弄死他。

暂时还没有九种,以后会有的。每种方法随着安全性上升,易用性难免稍有降低。想学习时还要先花一秒钟输入密码,不能现在,立刻,马上学,会打击孩子的学习积极性。因此对应学习习惯,选择适合的使用方法非常重要。

缚道之九十七:「深度隐藏」

脚本使用极易上手,直接放到你想隐藏文件和文件夹的地方,双击运行会隐藏同级所有文件和文件夹,再次双击则恢复显示,再双击又隐藏,又显示,就是这么简单暴力,却好用。隐藏后如果还能看到缓存的文件图标,刷新一下,或者退到上层重新进入文件夹就看不到了。

或者如果记得路径的话,都不用恢复显示,直接Win+R输入路径打开文件夹。比如我想复习一下科学发展观,输入c:\_Folder Locker demo\科学发展观 一敲回车就完事了。但一定注意,Win+R所有输入过的命令都有记录。

隐藏后,即使勾选「显示隐藏文件」或者查看命令行,也无法轻易看到被隐藏的文件和文件夹。这样别说一般人,甚至一些菜狗程序员都不会觉察发生肾么事了。如果想做得更绝,可以隐藏后将脚本文件移走,当个钥匙一样,想显示时再放回来运行。只要自己记得哪里有隐藏文件,别误删了就行。

是的,资源管理器和命令行只需稍作修改,仍可以显示这些文件。但我不太想贴出来如何操作,也请知道的朋友们看破不说破。因为既然来到这个问题,想必大家都是难兄难弟难姐难妹。知道的人越少,我们的学习资料越安全,这也是这篇文章设为禁止转载的唯一原因。爱学习的人,是可以相互帮助的。

缚道之九十八:「加密深度隐藏」

这一层进阶功能的初衷主要是防止好奇心强的人误运行脚本,意外看到学习资料,获得了并不属于他的知识,导致世界线偏移,最终引发世界大战(并不)。

密令/密码设置很简单(为区别于下一种方法所提及的密码,暂且把这里的密码称作「密令」),只需如下图所示,将script_passphrase改成自定密令,便会在显示隐藏文件前先要求提供密令。一般人看到弹出来个小黑框,还这么多洋码子,也就不敢继续瞎翻了。

我习惯在隐藏文件的地方都留一份脚本(反正也就几KB),使用不同密令,脚本文件名也改成提示在这隐藏了什么文件,而不是此地无银三百两的toggle_secret_files。做到这一级,我的大部分学习资料基本就有恃无恐了。(要高考的朋友不要这样用这个词)

缚道之九十九:「套娃加密深度葫芦娃救爷爷式套娃加密深度隐藏」

然鹅,天下没有不透风的防火墙。一些聪明逼,或者菜狗程序员都知道,脚本文件就是文本文档,上述密令直接是明文存储在脚本中的,如果通过文本编辑器打开则很容易被发现。此时,只需从容结印,祭出禁术:码遁「套娃加密深度葫芦娃救爷爷式套娃加密深度隐藏」之术,便可轻松把这些聪明逼治得死死的。

名号越长,杀招越狠,此言非虚。这招「套娃加密...」(你闭嘴吧)狠就狠在他大道无形,不是具体某招某式,而是一种思路,一种火之意志,一种誓死保卫珍贵学习资料的亮剑精神。

脚本缚道之九十七:「深度隐藏」已经把学习资料们保护得很好了。脚本就像一把钥匙,我们现在只需再把钥匙保护起来。此时各种强大的加密压缩算法便可出场了,因为压缩耗时久的缺点,在KB级小钥匙文件面前完全不是问题。下次别人手欠想在你的学习资料文件夹中一探究竟时,等待他的只有一句冷冷的「解压密码不正确」。翻译翻译就是,「想要钥匙,您配吗,您配几把?」

同时,一个经过精心重命名的Half-Life 3.exe会像肉盾一样疯狂吸引仇恨,敌人在无法解压而气急败坏的情况下,首先想到的会是拷贝走压缩文件,自己慢慢暴力破解。不料这样却正中下怀,完全不会注意到,隐形小丑竟在我身边。

究极进化后的脚本便将这一流程自动化了,兄弟姐妹只需如图所示,配置相应参数,脚本便可在隐藏文件后把自己也锁到一个自解压文件里。

script_passphrase是发动缚道之九十八所需要的密令,exe_password是缚道之九十九自解压文件的解压密码,exe_filename_w_extension是自解压文件的文件名,v是debug用的,可以先不管它。每个参数在旁边的注释中都有示例。留script_passphrase和exe_password为空,你发动的就是缚道之九十七。填上script_passphrase,你发动的就是缚道之九十八。如果同时填上exe_password,那你发动的就是缚道之九十八和缚道之九十九的结合体,缚道之九千零七十二,蓝染都看不了你的学习资料。

需要注意的是,缚道之九十九需要在电脑中装有强大开源免费的7-Zip压缩程序,在这里下载 。如果你没使用过7z,本人无利益相关地强烈推荐。装了这款仅有1.4MB的良心压缩软件,其他什么天朝特供WinRAR,360压缩,2345之流,还有他们捆绑的七大姑八大姨们,都可以卷铺盖滚蛋了。

三种使用方法,总有一款适合好学的你。

注意事项


最需要注意的是,如果你在系统设置中打开了「最近使用的文件」,那么即使隐藏文件,文件名仍会出现在快速访问和软件的最近使用文件列表中。很简单,关掉这个功能就可以了,不要让境外敌对势力有机可乘。

如果忘记密码或密令,解决方法也很简单,但还是不方便说得太明,因为可能会被敌人利用从而绕过密码。只需参悟,「最高端的食材,往往只需要最简单的烹饪」。最究极的杀招,有时会也化于最初级的破解。

使用方法

看到这里,心动不如行动。只需复制文末代码框中的代码,新建一个TXT文本文档,把代码粘贴进去,然后把文本文档扩展名改为.bat就可以啦。文件名随便,比如 学无止境从入门到出家.bat 。代码显得很长是因为大部分都是注释,这是我写的第一个batch script,所以也是现学现注释。嫌长删掉注释完全oj8k。很惭愧,就做了一点微小的工作,谢谢大嘎。

代码本码

:: Hide and Lock Files and Folders on Windows PC
::
:: hss@hss.wiki
::
:: Hiding files and folders in the same folder with this script by setting
:: their System and Hidden attributes. Those "secret files" (and folders)
:: cannot be easily shown in file explorer or by using `dir` in CMD.
::
:: Basic usage: Put this BAT file into the folder that you want to hide its
:: files and subfolders. Double click the script to hide the files. Refresh if
:: needed to see the effect. To reveal those files and folders, simply double
:: click the script again.
::
:: Intermediate usage: Set a passphrase under the "Config" section of this
:: script, and it will be asked before revealing any secret files. The files
:: can be hidden same as above.
::
:: Advanced usage: Set an EXE password under the "Config" section, and the
:: script will be locked into a self-extracting EXE after hiding files and
:: folders. To reveal the files, first, double click the EXE and enter the
:: password to release the BAT script. Then, double click the script to reveal
:: secret files. See the "Config" section for details.
::
:: The installation of [7-Zip](https://www.7-zip.org/) (about 1.4 MB) is
:: required if want to adopt the advanced usage. While script passphrase, EXE
:: filename, and password should work well with whitespaces, we advise you not
:: to, since they haven't been thoroughly tested. All of them are case
:: sensitive, but none of them supports special characters yet.

:: ############################################################################
::   Program logic
:: ############################################################################
::
:: If the current folder contains any visible files/subfolders:
::     Hide them all as secret files/folders. Note that this script will not be
::     hidden.
::
::     If `exe_password` is configured:
::         Lock this script into an EXE file encrypted with the given password.
::
::         If `exe_filename_w_extension` is configured:
::             Name the EXE file as given.
::
:: Else:
::     Reveal all secret files/folders in the current folder. Also, remove the
::     EXE where this script extracts from if possible.
::
::     If `script_passphrase` is configured:
::         Request passphrase before revealing any secret files or folders.
::
:: If `v` is configured:
::     Run the script in verbose mode.

:: ############################################################################
::   Config
:: ############################################################################

:: ============================================================================
::   Request passphrase before revealing any secret files or folders
:: ============================================================================

set "script_passphrase="

:: Add your passphrase after the equal sign. For example, `set
:: "script_passphrase=Alohomora"`. To turn off passphrase verification, edit it
:: back to `set "script_passphrase="`.

:: ============================================================================
::   Lock this script into an encrypted EXE file after hiding secret files
:: ============================================================================

set "exe_password="

:: After the equal sign, add your password to encrypt the BAT script into an
:: EXE. To keep the BAT script as is after hiding secret files, edit it back to
:: `set "exe_password="`.

:: ============================================================================
::   Name the EXE file
:: ============================================================================

set "exe_filename_w_extension=.toggle_secret_files.exe"

:: By default, the EXE file is named as `.toggle_secret_files.exe`. Note that
:: only when `exe_password` is defined, the BAT script will be locked into an
:: encrypted EXE named as above, after hiding secret files. Setting only the
:: EXE filename without password will not encrypt the BAT into EXE.

:: ============================================================================
::   Toggle verbose mode
:: ============================================================================

set "v="

:: Turn on to print logging messages to the console and leave the console open
:: upon finish. For example, `set "v=_true"` will turn it on, and `set "v="`
:: will turn it off.

:: ############################################################################
::   Implementation
:: ############################################################################

cls
:: Clear screen

@echo off
:: @ symbol for less verbose. `echo off`: hide the prompt for each command.

:: ============================================================================
::   Main
:: ============================================================================

:: - Validate configs
:: - Catalog current files and folders
:: - Toggle secret files and folders
:: - Lock the script into an encrypted EXE if required
:: - End

:: ============================================================================
::   Validate configs
:: ============================================================================

if defined v (
    if not defined exe_password (
        echo Script will not be encrypted since EXE password is not defined.
    ) else (
        echo EXE password: `%exe_password%`.
        echo EXE filename: `%exe_filename_w_extension%`.
    )
    echo.
)
:: `echo:` or `echo.` to echo a blank line.

:: Remove residual EXE file if possible. It may exist after self-extracting
:: to get this script.

del "%exe_filename_w_extension%" 2> nul

:: ============================================================================
::   Catalog current files and folders
:: ============================================================================

:: Save names of files/folders under current directory as indexed variables.
:: Ref: https://stackoverflow.com/a/19542051

setlocal enableDelayedExpansion
set "script_filename_w_extension=%~nx0"
:: `%~n0` stores current file name, x for extension.
:: Ref: https://stackoverflow.com/a/15568171. Substitute 1 with 0.

:: Catalog secret files and folders
set /a counter = 0
set /a n_secret_files = 0
:: `/a` for numeric.

for /f "tokens=1* delims=:" %%a in ('dir /ahs /b 2^>nul ^|findstr /n "^"') do (
    if not "%%b" == "%script_filename_w_extension%" (
        set /a counter += 1
        set "secret_file_number_!counter!=%%b"
        set "n_secret_files=!counter!"
    )
)
:: `%%a` and `%%b` are local iterator vars.

:: Excluding this script since we don't want to hide it. Uses double quotes
:: since filename can contain whitespaces.

:: `dir /ahs /b 2^>nul ^|findstr /n "^"` is a command-line command to list and
:: filter directories. `^` is used to escape special chars.

:: `dir /a`: display only with certain attributes. `d`: directories, `h`:
:: hidden, `s`: system. `/b`: bare list.
:: Ref: https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/dir

:: `2^>nul` redirects the command's stderr (2. 0 for stdin, 1 for stdout.) and
:: discard it, in order to suppress the "File Not Found" error when there's no
:: results. `|` pipes the former's stdout to the latter's stdin.
:: Ref: https://stackoverflow.com/a/62268165, https://stackoverflow.com/a/46956193, https://stackoverflow.com/a/20298717

:: Catalog all files and folders
set /a counter = 0
set /a n_files = 0

for /f "tokens=1* delims=:" %%a in ('dir /a /b 2^> nul ^|findstr /n "^"') do (
    if not "%%b" == "%script_filename_w_extension%" (
        set /a counter += 1
        set "file_number_!counter!=%%b"
        set "n_files=!counter!"
    )
)

if defined v (
    echo Here we have %n_secret_files% secret files/folders out of ^
%n_files% files/folders in total.
    echo.
)

if %n_files% == 0 (
    echo INFO: Current directory is empty.
    echo.
    goto terminate_and_display_error_message
)

:: ============================================================================
::   Toggle secret files and folders
:: ============================================================================

if %n_files% gtr %n_secret_files% (
    @REM Boolean operators: https://stackoverflow.com/a/18499854
    @REM There's no and/or operators in batch script.
    if %n_files% == 0 goto end
    if defined v echo Will hide visible files and folders.
    goto hide_all_files
) else (
    if defined v echo Will reveal secret files and folders.

    if defined script_passphrase (
        if defined v (
            echo Script passphrase required.
            echo.
        )
        :require_passphrase_to_reveal_files
        echo Enter passphrase to reveal secret files and folders:
        set /p "user_input_passphrase=>"
        @REM `>` will show in the console.
        if "!user_input_passphrase!" == "%script_passphrase%" (
            @REM Double-quote in case passphrase contains whitespaces.
            @REM Note the use of delayed expansion here. Otherwise it won't
            @REM work in the first iteration even if the passphrase is correct.
            if defined v echo Passphrase match.
            goto reveal_secret_files
        ) else (
            echo Passphrase does not match.
            goto require_passphrase_to_reveal_files
        )
    ) else (
        if defined v (
            echo Script passphrase disabled.
            echo.
        )
        goto reveal_secret_files
    )
)

:hide_all_files
for /l %%n in (1 1 %n_files%) do (
    attrib "!file_number_%%n!" +h +s
    @REM Note the double quotes in case filename contains whitespaces.
    if defined v echo Hid `!file_number_%%n!`.
)
if defined v (
    echo Successfully hid all %n_files% files and folders.
    echo.
)
goto self_encrypt_and_archive

:reveal_secret_files
for /l %%n in (1 1 %n_secret_files%) do (
    attrib "!secret_file_number_%%n!" -h -s
    if defined v echo Revealed `!secret_file_number_%%n!`.
)
if defined v (
    echo Successfully revealed all %n_secret_files% secret files and folders.
    echo.
)
goto end

:: ============================================================================
::   If applicable, self encrypt and archive after hiding secret files/folders
:: ============================================================================

:self_encrypt_and_archive
if defined exe_password (
    7z a -p"%exe_password%" -sdel -mhe=on ^
-sfx "%exe_filename_w_extension%" "%script_filename_w_extension%" > nul

    if defined v (
        echo Successfully locked the script into `%exe_filename_w_extension%` ^
with password `%exe_password%`.
        echo.
    )
)
:: `-sdel` to Self DELete files after archiving, `-sfx` to create a Self
:: EXtractable archive, `-mhe=on` to also encrypt archive HEaders (only works
:: for the 7z format, just leave it here for reference).

:: ============================================================================
::   End
:: ============================================================================

goto end
:terminate_and_display_error_message
cmd /k

:end

if defined v (
    cmd /k
)
:: Keep the CMD window open if verbose.

win10中自带加密功能,不过挺鸡肋的,知道用户登录密码登录之后照样能看到,于是找了很久,终于找到了2款免费好用的文件夹加密的软件,想要看文件必须输入密码,文件更安全,更适合使用在多人共享的电脑上。


1、Encrypto


网址:macpaw.com/encrypto


一款简单、安全性强的文件加密软件,支持 Windows 与 macOS 两大系统系统,而且免费无广告。


它采用的加密方式是高强度 AES-256 加密算法,安全性很高,几乎不可能被破解,不用担心加密文件的安全问题。


页面设计也非常简单,没有什么花里胡哨的功能,使用也非常简单,打开之后直接可以上传文件或者是文件夹进行加密,直接把需要加密的文件拖进去也行。



然后在下面Password输入密码,就开始为文件进行加密,加密的速度还挺快的。



加密之后将加密文档保存到任意位置即可,下次需要打开文件的时候,直接双击或者是将加密文件拖入到软件中,输入密码就可以解除密码查看文件内容了。



这个软件主要是给文件生成一个加密文件,所以在加密之后原文件需要进行删除,解密的时候也会重新给你生成一个可查看的文件。


虽然可能来回保存文件稍微有一写麻烦,但是加密效果还是很不错的,可以用来加密一些办公文件、个人文件什么的。


2、Anvi Folder Locker


网址:官网无法访问,可搜索其他网站下载


一款功能更加丰富的文件加密软件,同样是免费无广告,可以设置多种文件、文件夹访问权限,而且不会对文件本身进行修改,所以不需要等待加密、解密等操作时间。


第一次打开使用的时候,就会让你设置一个主密码,在之后打开软件的时候需要使用密码才能进入。



设置完密码之后,进入软件首页,就可以上传文件或者是文件夹,也可以直接将文件或者文件夹直接拖入到软件中。



点击文件后面的保护方式,支持选择多种保护方式,包括隐藏、锁定、只读、隐藏并锁定、密码,可以根据自己不同的加密需求进行选择。



隐藏:不管在任何管理器界面,都看不到隐藏的文件或者文件夹。


锁定:可以看到文件或者文件夹,但是打开之后就会提醒拒绝访问,看不到具体内容。



隐藏并锁定:隐藏之后,在任何资源管理界面都看不到文件夹的存在,当你需要使用的时候,只需要进入软件中,将文件的保护方式调整为不保护,或者是直接删除文件就可以重新找到文件。



密码:选择密码的保护方式,自己可以设置文件访问密码,可以选择主密码,就是一开始你设置的密码,也可以单独设置密码。



设置密码之后,点击文件输入密码,就可以正常访问文件。



你也不用担心别人打开这个软件,或者是想通过卸载这个软件打开加密文件,这些操作都是需要密码才能操作的,安全性没有问题。


以上,就是两个比较好用的文件/文件夹加密软件,可以根据自己平时加密文件的需求选择使用。


最后,如果对你有帮助,就点赞支持一下吧!