产生随机文件并加解密
2015-05-15 11:15
176 查看
因测试需要,需对随机文件并加解密
[root@test]# cat /dev/urandom | sed 's/[^a-zA-Z0-9]//g' | strings -n 8|head -n 10
q09zp7Zw
0T75nYDY
HGRl2A0Dk
J21n5sqX
lS7bPTWvT
OAgVNQxbyL
t5Tsp0cj
AnXbKScQ
6h4M9Q7Cf
iqnH3BvCt
产生一个8个随机字符串,10行的文件
[root@test]# cat /dev/urandom | sed 's/[^a-zA-Z0-9]//g' | strings -n 8|head -n 10 >test.txt
[root@test]# cat test.txt
zt2DLBRH
EkBiFyi6
ScfAzUak
g46Dbgs8
9Du9Dsno
4zqHwJU1
GYkDkvXm
ZqgFoql8
6fJVyBbZM
K0Vk4ibK
加密文件
# gpg -c test.txt
+-----------------------------------------------------+
| Enter passphrase |
| |
| |
| Passphrase ____________________ |
| |
| <OK> <Cancel> |
+-----------------------------------------------------+
生成test.txt.gpg
rm test.txt
解密
gpg test.txt.gpg
[root@test]# cat /dev/urandom | sed 's/[^a-zA-Z0-9]//g' | strings -n 8|head -n 10
q09zp7Zw
0T75nYDY
HGRl2A0Dk
J21n5sqX
lS7bPTWvT
OAgVNQxbyL
t5Tsp0cj
AnXbKScQ
6h4M9Q7Cf
iqnH3BvCt
产生一个8个随机字符串,10行的文件
[root@test]# cat /dev/urandom | sed 's/[^a-zA-Z0-9]//g' | strings -n 8|head -n 10 >test.txt
[root@test]# cat test.txt
zt2DLBRH
EkBiFyi6
ScfAzUak
g46Dbgs8
9Du9Dsno
4zqHwJU1
GYkDkvXm
ZqgFoql8
6fJVyBbZM
K0Vk4ibK
加密文件
# gpg -c test.txt
+-----------------------------------------------------+
| Enter passphrase |
| |
| |
| Passphrase ____________________ |
| |
| <OK> <Cancel> |
+-----------------------------------------------------+
生成test.txt.gpg
rm test.txt
解密
gpg test.txt.gpg
相关文章推荐
- 有一个数据文件:123 34 17 651234 345….这些数据都是随机产生的,编写程序读出该文件.并将其以从大到小的顺序输出到另一个文件中.
- 用LR录制文件下载并随机产生文件名
- 用vb6制作随机产生文件把硬盘塞满!
- 用VB产生随机任意大小文件挤满硬盘
- 用VB产生随机任意大小文件挤满硬盘
- 文件——文件指针——文件练习(随机产生N个手机号)——自动关文件
- 如何在 Linux 中产生、加密或解密随机密码
- 在Linux 中产生和加密解密随机密码的教程
- 用LR录制文件下载并随机产生文件名
- 如何在 Linux 中产生、加密或解密随机密码
- 用vb6制作随机产生文件把硬盘塞满!
- java调用AES算法产生密钥并加解密文件
- 高并发下产生大量,随机,唯一的字符串,并输出到文件中
- 在Linux中产生加密或解密随机密码
- 随机产生一个小写字母
- 软件工程概论第一次课堂小测-------产生30个100以内的随机整数四则运算的小程序
- 关于一道 产生一个int数组,长度为100,并向其中随机插入1-100,并且不能重复
- php从文件夹随机读取文件的方法
- Spring 管理下的web项目,对Properties文件重要参数的加密解密处理(续)