开发工具:
文件大小: 675byte
下载次数: 0
上传时间: 2011-07-22
详细说明: 写了个linux平台加密程序ende 共两个程序 (一) 用tar打包压缩一个文件夹后用openssl的AES256加密 #!/bin/bash # Use openssl to encrypt one folder. # # Usage: # en infolder # Result: # infolder.tar.gz.aes256cbc # # Note: # 1) tar zcvf => openssl # 2) Don't use space in folder[or path]! # # Version: # v0.1[20110721] # Author: # JEF [dungeonsnd@126.com] # (二) 用openssl的AES256-cbc解密一个文件成一个tar.gz包,然后解包成一个文件夹 #!/bin/bash # Use openssl to decrypt one folder. # Usage: # en InFolder.tar.g z.aes256cbc # Note: # 1) Don't use space in InFolder! # 2) openssl => tar zxvf # # # Version: # v0.1[20110721] # Author: # JEF [dungeonsnd@126.com] # ============================================================== (三) 使用试例 view plain dnd@linux-ibzb:~/doc/fromdisk/Tech/MySrc/t> ll total 4 drwxr-xr-x 2 dnd users 4096 Jul 22 11:46 myfolder dnd@linux-ibzb:~/doc/fromdisk/Tech/MySrc/t> cd myfolder/ dnd@linux-ibzb:~/doc/fromdisk/Tech/MySrc/t/myfolder> ll total 8 -rw-r--r-- 1 dnd users 4 Jul 22 11:46 infile2.txt -rw-r--r-- 1 dnd users 21 Jul 22 11:46 infile.txt dnd@linux-ibzb:~/doc/fromdisk/Tech/MySrc/t/myfolder> cat infile.txt abc你好?? !!好啊 dnd@linux-ibzb:~/doc/fromdisk/Tech/MySrc/t/myfolder> cat infile2.txt aaa dnd@linux-ibzb:~/doc/fromdisk/Tech/MySrc/t/myfolder> cd .. dnd@linux-ibzb:~/doc/fromdisk/Tech/MySrc/t> ll total 4 drwxr-xr-x 2 dnd users 4096 Jul 22 11:46 myfolder dnd@linux-ibzb:~/doc/fromdisk/Tech/MySrc/t> en myfolder/ =========================================== [Now,tar will compress myfolder to myfolder.tar.gz,please wait......] myfolder/ myfolder/infile.txt myfolder/infile2.txt =========================================== [Now,openssl will encrypt myfolder.tar.gz to myfolder.tar.gz.aes256cbc,please wait......] enter aes-256-cbc encryption password: Verifying - enter aes-256-cbc encryption password: =========================================== [Now,script finished successfully!] dnd@linux-ibzb:~/doc/fromdisk/Tech/MySrc/t> dnd@linux-ibzb:~/doc/fromdisk/Tech/MySrc/t> ll total 8 drwxr-xr-x 2 dnd users 4096 Jul 22 11:46 myfolder -rw-r--r-- 1 dnd users 325 Jul 22 13:14 myfolder.tar.gz.aes256cbc dnd@linux-ibzb:~/doc/fromdisk/Tech/MySrc/t> mv myfolder myfolder.bk dnd@linux-ibzb:~/doc/fromdisk/Tech/MySrc/t> ll total 8 drwxr-xr-x 2 dnd users 4096 Jul 22 11:46 myfolder.bk -rw-r--r-- 1 dnd users 325 Jul 22 13:14 myfolder.tar.gz.aes256cbc dnd@linux-ibzb:~/doc/fromdisk/Tech/MySrc/t> de myfolder.tar.gz.aes256cbc =========================================== [Now,openssl will decrypt myfolder.tar.gz.aes256cbc to myfolder.tar.gz,please wait......] enter aes-256-cbc decryption password: =========================================== [Now,tar will extract myfolder.tar.gz to myfolder.,please wait......] myfolder/ myfolder/infile.txt myfolder/infile2.txt =========================================== [Now,script finished successfully!] dnd@linux-ibzb:~/doc/fromdisk/Tech/MySrc/t> ll total 12 drwxr-xr-x 2 dnd users 4096 Jul 22 11:46 myfolder drwxr-xr-x 2 dnd users 4096 Jul 22 11:46 myfolder.bk -rw-r--r-- 1 dnd users 325 Jul 22 13:14 myfolder.tar.gz.aes256cbc dnd@linux-ibzb:~/doc/fromdisk/Tech/MySrc/t> cd myfolder dnd@linux-ibzb:~/doc/fromdisk/Tech/MySrc/t/myfolder> ll total 8 -rw-r--r-- 1 dnd users 4 Jul 22 11:46 infile2.txt -rw-r--r-- 1 dnd users 21 Jul 22 11:46 infile.txt dnd@linux-ibzb:~/doc/fromdisk/Tech/MySrc/t/myfolder> cat infile.txt abc你好?? !!好啊 dnd@linux-ibzb:~/doc/fromdisk/Tech/MySrc/t/myfolder> cat infile2.txt aaa dnd@linux-ibzb:~/doc/fromdisk/Tech/MySrc/t/myfolder> dnd@linux-ibzb:~/doc/fromdisk/Tech/MySrc/t/myfolder> ll /usr/bin/en -rwxr-xr-x 1 root root 827 Jul 22 13:00 /usr/bin/en dnd@linux-ibzb:~/doc/fromdisk/Tech/MySrc/t/myfolder> ll /usr/bin/de -rwxr-xr-x 1 root root 715 Jul 22 13:00 /usr/bin/de dnd@linux-ibzb:~/doc/fromdisk/Tech/MySrc/t/myfolder> 可以看到,加密一个文件夹使用如下命令: en foldername 而解决刚才的文件夹使用如下命令 de filename 另外,如果想使用另外的加密算法要改这两个脚本。目前是使用openssl库的,AES256-cbc. 所以你的linux机器上一定要安装成功openssl(直接在终端敲入"openssl",如果成功进入openssl程序则说明安装好了openssl了,那么这两个脚本可以直接用,否则要先到openssl官网下载并安装之). 详细用法见作者博客。 ...展开收缩
(系统自动生成,下载前可以参看下载内容)
下载文件列表
相关说明
- 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
- 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度。
- 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
- 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
- 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
- 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.