面试题答案
一键面试- 确保系统安装了OpenSSL工具,如果没有安装,根据不同系统进行安装,例如在Ubuntu系统上:
sudo apt-get install openssl
- 编写Bash脚本进行解密,脚本内容如下:
#!/bin/bash
openssl enc -d -aes-256-cbc -in encrypted.txt -out decrypted.txt -k password
上述命令解释:
openssl enc
:OpenSSL的加密/解密命令。-d
:表示解密操作。-aes-256-cbc
:指定使用AES - 256 - CBC加密算法(如果加密时使用的是其他算法,这里需对应修改)。-in encrypted.txt
:指定输入文件为encrypted.txt
。-out decrypted.txt
:指定输出文件为decrypted.txt
。-k password
:指定解密密钥为password
。
- 给脚本添加可执行权限:
chmod +x decrypt_script.sh
- 运行脚本:
./decrypt_script.sh