OpenSSL: enc symmtric key encryption
Symmetric key encryption is performed using the enc
operation of OpenSSL.
查看可用encryption
openssl enc -list
Encrypt
use -pass pass:minutia 指定密码
openssl enc -e -aes-256-cbc -p -pass pass:minutia -in netconfig -out netconfig.enc
-aes-256-cbc
the cipher name (symmetric cipher: AES; block to stream conversion: CBC (cipher block chaining)
-pass pass:<password>
to specify the password
-p
print out the salt, key and IV used
-base64
密文使用base64 encode
-nosalt
Do not use salt
-S salt
Also you can specify the salt value with the -S
flag.If you provide the salt value, then you become responsible for generating proper salts, trying to make them as unique as possible (in practice, you have to produce them randomly). It is preferable to let openssl
handle that.
.
Decrypt
openssl enc -aes-256-cbc -pass pass:minutia -d -p -in netconfig.enc -out netconfig~