Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4460977
  • 博文数量: 1214
  • 博客积分: 13195
  • 博客等级: 上将
  • 技术积分: 9105
  • 用 户 组: 普通用户
  • 注册时间: 2007-01-19 14:41
个人简介

C++,python,热爱算法和机器学习

文章分类

全部博文(1214)

文章存档

2021年(13)

2020年(49)

2019年(14)

2018年(27)

2017年(69)

2016年(100)

2015年(106)

2014年(240)

2013年(5)

2012年(193)

2011年(155)

2010年(93)

2009年(62)

2008年(51)

2007年(37)

分类: 网络与安全

2014-12-08 15:55:20

文章来源:

Suppose you want to create a zip archive, but with password protection, so that whoever tries to uncompress the zip file must know the right password. On Linux, there are several ways to encrypt and password protect a zip file.

In this tutorial, I will describe how to create an encrypted zip file on Linux.

Method One

The zip command line tool provides an encryption option. The encryption algorithm used by zip command is. The PKZIP algorithm is known to be insecure. Also, the fact that the password is typed and shown in plain text makes it even more vulnerable.

To create an encrypted zip file with zip:

$ zip --password MY_SECRET secure.zip doc.pdf doc2.pdf doc3.pdf


To uncompress a zip file that is encrypted with zip command:

$ unzip secure.zip
Archive:  secure.zip
[secure.zip] doc.pdf password:

Method Two

7z file archiver can produce zip-format archives with more secure encryption scheme. According to , 7z archiver supports AES-256 encryption algorithm with SHA-256 hash algorithm based key generation.

To create an encrypted zip file with 7z archiver:

$ 7za a -tzip -pMY_SECRET -mem=AES256 secure.zip doc.pdf doc2.pdf doc3.pdf


To uncompress a zip file that is encrypted with 7za command:

$ 7za e secure.zip
7-Zip (A) [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,8 CPUs)

Processing archive: secure.zip

Extracting  doc.pdf
Enter password (will not be echoed) :

Method Three

Another way to create a secure zip archive is to use GnuPG's symmetric key encryption.

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


To uncompress an archive file encrypted with GnuPG:

$ gpg -d secure.tar.gz.gpg | tar xzvf -


文章来源:http://blog.ashurex.com/2012/07/17/encrypting-tar-gz-gzip-file-openssl/
Encrypt a tar file with OpenSSL, much easier than gpg.
Encrypting:
tar cvzf - mysql_dump.sql | openssl des3 -salt -k #YOUR PASSWORD# | dd of=encrypted_mysql_dump
Decrypting:
dd if=encrypted_mysql_dump |openssl des3 -d -k #YOUR PASSWORD# |tar xvzf -

阅读(883) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~