如何在Linux中使用ZIP和7zip加密/解密和密码保护文件/文件夹 |
您所在的位置:网站首页 › 7zip密码 › 如何在Linux中使用ZIP和7zip加密/解密和密码保护文件/文件夹 |
到目前为止,我们已经涵盖了许多有关文件和文件夹加密与解密的文章。 在本文中,我们将向您展示如何使用本地zip和7zip归档文件在Linux中加密/解密文件和文件夹。 我们都知道zip和7zip档案,但是我们甚至没有一次使用密码保护。 当您没有用于加密的实用程序时,可以将其用于紧急目的。 加密是使用标准加密算法对文件进行编码的过程,该算法仅允许授权用户查看。 已知Note : zip加密方法不安全,因此请使用7zip而不是zip。 建议阅读: (#)Cryptkeeper –一种在Linux中加密和解密文件夹或目录的简便方法 (#)GnuPG –在Linux中从命令行加密/解密文件的简便方法 (#)SiriKali – GUI前端,用于管理ecryptfs,cryfs,gocryptfs,securefs和encfs加密文件夹 (#)Gnome Encfs Manager –在Linux中创建加密目录的简便方法 (#)Steghide –在Linux中隐藏图像和声音对象内部机密数据的简便方法 (#)Cipher –在Linux命令行中用于加密/解密文件和目录的两个简单命令 (#)如何在Linux中使用VIM编辑器加密/解密和密码保护文件 由于PKZIP流密码算法,已知Zip加密不安全。 7zip压缩方法支持使用AES-256算法进行加密。 此算法使用SHA-256位长度的密码密钥。 什么是ZIPzip是用于Unix / Linux操作系统的压缩和文件打包实用程序。 该程序对于打包一组文件进行分发非常有用; 用于存档文件; 并通过临时压缩未使用的文件或目录来节省磁盘空间。 zip程序将一个或多个压缩文件以及有关文件的信息(名称,路径,日期,最后修改时间,保护和检查信息以验证文件完整性)放入单个zip存档中。 如何在Linux上安装Zip / Unzip在大多数操作系统自己的存储库中都可以使用Zip。 这些实用程序尚未预安装,因此请使用发行版正式存储库进行安装。 对于Debian / Ubuntu,请使用apt-get命令或apt命令安装zip。 1$ sudo apt-get install zip unzip对于RHEL / CentOS,使用yum命令安装zip。 1$ sudo yum install zip unzip对于Fedora,请使用dnf命令安装zip。 1$ sudo dnf install zip unzip对于Arch Linux,请使用pacman命令安装zip。 1$ sudo pacman -S zip unzip对于openSUSE,请使用zypper命令安装zip。 1$ sudo zypper install zip unzip 如何使用zip加密/解密文件使用以下格式创建加密的zip文件。 在此示例中,我们将使用test.txt和test1.txt文件创建一个名为test.zip的加密zip文件。 12345# zip --encrypt test.zip test.txt test1.txt Enter password: ****** Verify password: ***** adding: test.txt (stored 0%) adding: test1.txt (stored 0%)细节 : zip:命令 –encrypt:创建加密 test.zip:Zip文件名 test.txt和test1.txt:这些是要加密的文件 要解压缩加密的zip文件,只需运行以下命令并输入一次密码即可。 1234567# unzip test.zip Archive: test.zip [test.zip] test.txt password: ****** replace test.txt? [y]es, [n]o, [A]ll, [N]one, [r]ename: y extracting: test.txt replace test1.txt? [y]es, [n]o, [A]ll, [N]one, [r]ename: y extracting: test1.txt对于flder加密,请在zip命令中使用-r选项。 在此示例中,我们将使用test.txt,test1.txt文件和test-dir文件夹创建一个名为test1.zip的加密zip文件。 12345678# zip -r --encrypt test1.zip test.txt test1.txt test-dir/ Enter password: ****** Verify password: ****** adding: test.txt (stored 0%) adding: test1.txt (stored 0%) adding: test-dir/ (stored 0%) adding: test-dir/test1.txt (stored 0%) adding: test-dir/test.txt (stored 0%)要解压缩加密的zip文件夹,只需运行以下命令并输入一次密码即可。 1234567891011# unzip test1.zip Archive: test1.zip [test1.zip] test.txt password: ****** replace test.txt? [y]es, [n]o, [A]ll, [N]one, [r]ename: y extracting: test.txt replace test1.txt? [y]es, [n]o, [A]ll, [N]one, [r]ename: y extracting: test1.txt replace test-dir/test1.txt? [y]es, [n]o, [A]ll, [N]one, [r]ename: y extracting: test-dir/test1.txt replace test-dir/test.txt? [y]es, [n]o, [A]ll, [N]one, [r]ename: y extracting: test-dir/test.txt 什么是7zip7z是新的存档格式,通过LZMA和LZMA2压缩提供高压缩率。 通常,7-Zip压缩到7z格式的压缩率比zip压缩好30-70%。 并且7-Zip压缩为zip格式比大多数其他与zip兼容的程序要好2-10%。 7-Zip还支持使用AES-256算法进行加密。 该算法使用长度为256位的密码密钥。 如何在Linux上安装7zip大多数操作系统自己的存储库中都提供7zip。 它尚未预安装,因此请使用发行版正式存储库进行安装。 对于Debian / Ubuntu,请使用apt-get命令或apt命令安装7zip。 1$ sudo apt-get install p7zip-full p7zip-rar对于RHEL / CentOS,启用EPEL存储库并使用yum命令安装7zip。 1$ sudo yum install p7zip p7zip-plugins对于Fedora,请使用dnf命令安装7zip。 1$ sudo dnf install p7zip p7zip-plugins对于Arch Linux,请使用pacman命令安装7zip。 1$ sudo pacman -S p7zip对于openSUSE,请使用zypper命令安装7zip。 1$ sudo zypper install p7zip 如何使用7zip加密/解密文件使用以下格式,使用7zip创建加密的zip文件。 在此示例中,我们将使用test.txt和test1.txt文件创建一个名为test.7z的加密7zip文件。 12345678910111213141516171819# 7z a -p -mx=9 -mhe -t7z test.7z text.txt text1.txt 7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21 p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,1 CPU Intel Core Processor (Haswell, no TSX) (306C1),ASM,AES-NI) Scanning the drive: 2 files, 68 bytes (1 KiB) Creating archive: test.7z Items to compress: 2 Enter password (will not be echoed): ****** Verify password (will not be echoed) : ****** Files read from disk: 2 Archive size: 261 bytes (1 KiB) Everything is Ok细节 : 7z:命令 a:添加 -p:设置密码 -mx = 9:超压缩 -mhe:加密文件名 -t7z:文件类型.7z test.7z:7zip文件名 test.txt和test1.txt:要加密的文件 要解压缩7zip加密文件,只需运行以下命令并输入一次密码即可。 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647# 7za e test.7z 7-Zip (a) [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21 p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,1 CPU Intel Core Processor (Haswell, no TSX) (306C1),ASM,AES-NI) Scanning the drive for archives: 1 file, 261 bytes (1 KiB) Extracting archive: test.7z Enter password (will not be echoed): -- Path = test.7z Type = 7z Physical Size = 261 Headers Size = 213 Method = LZMA2:12 7zAES Solid = + Blocks = 1 Would you like to replace the existing file: Path: ./text.txt Size: 34 bytes (1 KiB) Modified: 2017-08-21 03:29:06 with the file from archive: Path: text.txt Size: 34 bytes (1 KiB) Modified: 2017-08-21 03:29:06 ? (Y)es / (N)o / (A)lways / (S)kip all / A(u)to rename all / (Q)uit? y Would you like to replace the existing file: Path: ./text1.txt Size: 34 bytes (1 KiB) Modified: 2017-08-21 03:29:20 with the file from archive: Path: text1.txt Size: 34 bytes (1 KiB) Modified: 2017-08-21 03:29:20 ? (Y)es / (N)o / (A)lways / (S)kip all / A(u)to rename all / (Q)uit? y Everything is Ok Files: 2 Size: 68 Compressed: 261对于flder加密,请在7zip命令中使用-r选项。 在此示例中,我们将使用test.txt,test1.txt文件和test-dir文件夹创建一个名为test1.7z的加密7zip文件。 12345678910111213141516171819# 7z a -p -mx=9 -mhe -t7z -r test1.7z text.txt text1.txt test-dir/ 7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21 p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,1 CPU Intel Core Processor (Haswell, no TSX) (306C1),ASM,AES-NI) Scanning the drive: 1 folder, 3 files, 102 bytes (1 KiB) Creating archive: test1.7z Items to compress: 4 Enter password (will not be echoed): ****** Verify password (will not be echoed) : ****** Files read from disk: 3 Archive size: 278 bytes (1 KiB) Everything is Ok要解压缩加密的7zip文件夹,只需运行以下命令并输入一次密码即可。 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859# 7za x test1.7z 7-Zip (a) [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21 p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,1 CPU Intel Core Processor (Haswell, no TSX) (306C1),ASM,AES-NI) Scanning the drive for archives: 1 file, 278 bytes (1 KiB) Extracting archive: test1.7z Enter password (will not be echoed): -- Path = test1.7z Type = 7z Physical Size = 278 Headers Size = 230 Method = LZMA2:12 7zAES Solid = + Blocks = 1 Would you like to replace the existing file: Path: ./test-dir/text.txt Size: 34 bytes (1 KiB) Modified: 2017-08-21 03:32:49 with the file from archive: Path: test-dir/text.txt Size: 34 bytes (1 KiB) Modified: 2017-08-21 03:32:49 ? (Y)es / (N)o / (A)lways / (S)kip all / A(u)to rename all / (Q)uit? y Would you like to replace the existing file: Path: ./text.txt Size: 34 bytes (1 KiB) Modified: 2017-08-21 03:29:06 with the file from archive: Path: text.txt Size: 34 bytes (1 KiB) Modified: 2017-08-21 03:29:06 ? (Y)es / (N)o / (A)lways / (S)kip all / A(u)to rename all / (Q)uit? y Would you like to replace the existing file: Path: ./text1.txt Size: 34 bytes (1 KiB) Modified: 2017-08-21 03:29:20 with the file from archive: Path: text1.txt Size: 34 bytes (1 KiB) Modified: 2017-08-21 03:29:20 ? (Y)es / (N)o / (A)lways / (S)kip all / A(u)to rename all / (Q)uit? y Everything is Ok Folders: 1 Files: 3 Size: 102 Compressed: 278 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |