Featured image of post OpenSSL 檔案加密解密

OpenSSL 檔案加密解密

加密
openssl enc -e -aes256 -in pwd -out pwd
解密
openssl enc -d -aes256 -in pwd -out pwd
測試
user@user-pc:~/$ cat file 
This is a file.
user@user-pc:~/$ openssl enc -e -aes256 -in file -out file_lock
enter aes-256-cbc encryption password:
Verifying - enter aes-256-cbc encryption password:
user@user-pc:~/$ ls
file  file_lock
user@user-pc:~/$ openssl enc -d -aes256 -in file_lock -out file_unlock
user@user-pc:~/$ ls
file  file_lock  file_unlock
user@user-pc:~/$ cat file_unlock 
This is a file.
user@user-pc:~/$ 

參考資料: 使用 OpenSSL 或 GnuPG 加密檔案與目錄,用密碼上鎖保護機密資料  

Licensed under CC BY-NC-SA 4.0