一. 利用openssl命令进行BASE64编码解码(base64 encode/decode)
- BASE64编码命令对字符串‘abc’进行base64编码:
echo abc | openssl base64
编码结果:
YWJjCg==
- BASE64解码命令、对base64后的字符串‘YWJjCg==’:
echo YWJjCg== | openssl base64 -d
编码结果:
abc
- 完整脚本
#!/bin/shpwd=123abcm_2023echo "加密前:" ${pwd}varrrrr=$(echo ${pwd} | openssl base64)echo "加密后:" ${varrrrr}jmh=$(echo ${varrrrr} | openssl base64 -d)echo "解密后:" ${jmh}
二. 利用openssl命令进行AES/DES3加密解密(AES/DES3 encrypt/decrypt)
- 对字符串‘abc’进行aes加密,使用密钥123,输出结果以base64编码格式给出:
echo abc | openssl aes-128-cbc -k 123 -base64结果:U2FsdGVkX1/b3Zl6+MGgEHOrQkCzmKYRr8zJtvpT5hg=
对以上结果进行解密处理:
echo U2FsdGVkX18ynIbzARm15nG/JA2dhN4mtiotwD7jt4g= | openssl aes-128-cbc -d -k 123 -base64
- 完整脚本
#!/bin/shpwd=123abcm_2023echo "加密前:" ${pwd}varrrrr=$(echo ${pwd} | openssl aes-128-cbc -k 123 -base64)echo "加密后:" ${varrrrr}jmh=$(echo ${varrrrr} | openssl aes-128-cbc -d -k 123 -base64)echo "解密后:" ${jmh}
来源地址:https://blog.csdn.net/a1150499208/article/details/129745652