Linux下创建加密的压缩文件

编程入门 行业动态 更新时间:2024-10-20 00:47:29

Linux下创建加密的<a href=https://www.elefans.com/category/jswz/34/1758321.html style=压缩文件"/>

Linux下创建加密的压缩文件

Linux下创建加密的压缩文件

  • 方法一:
    • 1.使用ZIP命令创建一个加密的ZIP文件:
    • 2.解压缩加密文件时,会提示要求输入密码:
  • 方法二:
    • 1.使用7z创建一个zip文件:
    • 2.解压缩加密文件:
    • 3.使用限制
  • 方法三:
    • 1.To create an encrypted compressed tar archive with GnuPG:
    • 2.To uncompress an archive file encrypted with GnuPG:

假设你想创建一个zip归档文件,并且具有密码保护,这样不管是谁试图解压这个zip文件时候,都必须知道正确的密码。在Linux上,有几种方法可以加密ZIP文件,或者对zip文件进行密码保护.

下面我们来介绍常用的3种加密方式:

方法一:

zip命令行工具提供了一个加密选项。
zip命令所使用的是PKZIP加密算法。
PKZIP算法被称为是不安全的。
此外,设置的密码,被以纯文本显示,使得它更加脆弱。

1.使用ZIP命令创建一个加密的ZIP文件:
$ zip --password mypasscode all.zip 1.txt 2.txtadding: 1.txt (stored 0%)adding: 2.txt (stored 0%)
2.解压缩加密文件时,会提示要求输入密码:
$unzip all.zipArchive:  all.zip[all.zip] 1.txt password:
方法二:

使用7z进行文件归档,可以创建更加安全的加密zip文件,7z使用AES-256加密算法,SHA-256散列算法生成密钥。

1.使用7z创建一个zip文件:
$ 7z a -t7z -p doc_folder.7z doc_folder7-Zip [64] 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18
p7zip Version 9.20 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,4 CPUs)
ScanningCreating archive doc_folder.7zEnter password (will not be echoed) :
Verify password (will not be echoed) :
Compressing  doc_folder/.7z      
Compressing  doc_folder/test.txt      Everything is Ok
2.解压缩加密文件:
$ 7z x doc_folder.7z7-Zip [64] 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18
p7zip Version 9.20 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,4 CPUs)Processing archive: doc_folder.7zEnter password (will not be echoed) :
Extracting  doc_folder/.7z
Extracting  doc_folder/test.txt
Extracting  doc_folderEverything is OkFolders: 1
Files: 2
Size:       37
Compressed: 252
3.使用限制

注意:如果要备份文件及文件owner/group,要先用tar打包

Backup and limitationsDO NOT USE the 7-zip format for backup purpose on Linux/Unix because :- 7-zip does not store the owner/group of the file.On Linux/Unix, in order to backup directories you must use tar :- to backup a directory  : tar cf - directory | 7za a -si directory.tar.7z- to restore your backup : 7za x -so directory.tar.7z | tar xf -If you want to send files and directories (not the owner of file) to others Unix/MacOS/Windows users, you can use the 7-zip format.example : 7za a directory.7z  directoryDo not use "-r" because this flag does not do what you think.Do not use directory/* because of ".*" files (example : "directory/*" does not match "directory/.profile")
方法三:

还有一种创建加密压缩包的方式,就是采用GnuPG的对称密钥加密

1.To create an encrypted compressed tar archive with GnuPG:
$ tar czvpf – doc.pdf doc2.pdf doc3.pdf | gpg --symmetric --cipher-algo aes256 -o secure.tar.gz.gpg
2.To uncompress an archive file encrypted with GnuPG:
$ gpg -d secure.tar.gz.gpg | tar xzvf -

转载于:.html

更多推荐

Linux下创建加密的压缩文件

本文发布于:2024-03-15 08:08:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1738451.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:压缩文件   Linux

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!