go - 如何解密使用 Openssl aes-256-cbc 加密的 Go 文件
问题描述
我正在使用 OpenSSL AES-256-CBC 加密我的一些文件
openssl aes-256-cbc -in filename.txt -out filename.enc -k password
如何在 Go 中解密这些文件?
解决方案
我希望这会有所帮助,请确保您在opensslEncrypted变量中读取文件字节:
安装
git clone https://github.com/funny/crypto
解密:
import (
"fmt"
"github.com/funny/crypto/aes256cbc"
)
func main() {
opensslEncrypted := "U2FsdGVkX19ZM5qQJGe/d5A/4pccgH+arBGTp+QnWPU="
passphrase := "z4yH36a6zerhfE5427ZV"
dec, err := aes256cbc.DecryptString(passphrase, opensslEncrypted)
if err != nil {
fmt.Printf("An error occurred: %s\n", err)
}
fmt.Printf("Decrypted text: %s\n", string(dec))
}
来源:github
推荐阅读
- angular - 切换侧导航单击背景时,材质按钮状态错误
- python - 在numpy的数组中查找数组元素的索引
- python - K中心问题的特定变体的实现
- stanford-nlp - 使用 wikidict 注释时的斯坦福 NER 4.2.2 问题
- regex - 匹配任何以字符开头的单词,Regex
- c++ - 使用 boost 或标准库的 wchar 参数
- microsoft-graph-teams - 用于获取 Teams 详细信息的嵌套 mgt-get 无法使用 Teams Toolkit
- sql - 检查一个表中的值组合是否存在于另一个表中
- uart - UART.init() 和 UART.deinit() 在 Raspberry Pi Pico 上的 MicroPython 1.16 中是否已弃用?两种方法都在文档中,但未被识别
- python - 如何将 pybind11::keep_alive 与返回不同类型对象的函数一起使用