利用openssl enc 实现简易的文件加密,解密
利用openssl enc 实现文件加密,解密
常用参数,含义
参数 |
含义 |
-in <file> |
输入文件 |
-out <file> |
输出文件 |
-pass <arg> |
密码 |
-S |
密码盐,用于加盐加密,请避免人为输入,下面讨论 |
-e |
encrypt 加密操作 |
-d |
decrypt 解密操作 |
-a/-base64 |
base64 encode/decode, depending on encryption flag 是否将结果base64编码 |
-k/-kfile |
已被-pass参数取代 |
-md |
指定**生成的摘要算法 默认MD5 |
-K/-iv |
加密所需的key和iv向量,由输入的-pass生成 |
-[pP] |
print the iv/key (then exit if -P) 是否需要在控制台输出生成的 key和iv向量 |
-bufsize <n> |
读写文件的I/O缓存,一般不需要指定 |
-engine e |
指定加密引擎 |
源文件
Source_file.txt 内容如下
Encode:加密
openssl enc -e -in source_file.txt -out encode_file.txt -des-cbc -pass pass:password
加密后的文件内容
Decode:解密
openssl enc -d -in encode_file.txt -out decode_file.txt -des-cbc -pass pass:password
加密语句,解密语句的区别在于 -e 参数 与 -d 参数