文件名称:linux平台加密程序ende
文件大小:675B
文件格式:GZ
更新时间:2014-08-11 07:14:43
linux 加密 ende tar 密码
写了个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.gz.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官网下载并安装之). 详细用法见作者博客。
【文件预览】:
ende
----v0.1()
--------de(715B)
--------en(827B)