Openssl AES-128-cbc 简单示例


[root@shanghai ~]# mkdir openssl 
[root@shanghai ~]# cd openssl
[root@shanghai openssl]# 
[root@shanghai openssl]# echo "Hello World" >> test.file
[root@shanghai openssl]# echo "Openssl 测试" >> test.file
[root@shanghai openssl]# cat test.file
Hello World
Openssl 测试
[root@shanghai openssl]# sha256sum test.file
6d237319262a82defa0efd736c29c3c824ed8ac5eb4c2f3703ef1041750ec4ca  test.file
[root@shanghai openssl]# 

[root@shanghai openssl]# openssl aes-128-cbc -e -K e212f28d932e79b1673944bd5a6e0811 -iv 67c6697351ff4aec29cdbaabf2fbe346 -in test.file -out enc.file 
[root@shanghai openssl]# openssl aes-128-cbc -d -K e212f28d932e79b1673944bd5a6e0811 -iv 67c6697351ff4aec29cdbaabf2fbe346 -in enc.file -out dec.file
[root@shanghai openssl]# sha256sum dec.file
6d237319262a82defa0efd736c29c3c824ed8ac5eb4c2f3703ef1041750ec4ca  dec.file
[root@shanghai openssl]# cat dec.file
Hello World
Openssl 测试
[root@shanghai openssl]# 


[root@shanghai openssl]# openssl aes-128-cbc --help
unknown option '--help'
options are
-in <file>     input file
-out <file>    output file
-pass <arg>    pass phrase source
-e             encrypt
-d             decrypt
-a/-base64     base64 encode/decode, depending on encryption flag
-k             passphrase is the next argument
-kfile         passphrase is the first line of the file argument
-md            the next argument is the md to use to create a key
                 from a passphrase. See openssl dgst -h for list.
-S             salt in hex is the next argument
-K/-iv         key/iv in hex is the next argument
-[pP]          print the iv/key (then exit if -P)
-bufsize <n>   buffer size
-nopad         disable standard block padding
-engine e      use engine e, possibly a hardware device.





猜你喜欢

转载自my.oschina.net/u/3776585/blog/1784692