openssl解密des"/>
使用openssl解密des
使用openssl解密des-ede3(go语言)
项目场景:
需解密数据库中通过des-ede3加密的字符串解决方案:
通过查找资料找到如下工具:
附代码:
func decodeDesEDE3(original string, key []byte) string {iv := []byte(nil)cipher, err := GetCipherByNid(NID_des_ede3)if err != nil {fmt.Println("Could not get cipher: ", err)}origianle_base64, err := base64.StdEncoding.DecodeString(original)dCtx, err := NewDecryptionCipherCtx(cipher, nil, key, iv)if err != nil {fmt.Println("Could not create decryption context: ", err)}// 1、plainbytes, err := dCtx.DecryptUpdate(origianle_base64)if err != nil {fmt.Println("DecryptUpdate(ciphertext) failure: ", err)}plainOutput := string(plainbytes)// 2、plainbytes, err = dCtx.DecryptFinal()if err != nil {fmt.Println("DecryptFinal() failure: ", err)}plainOutput += string(plainbytes)return plainOutput
}
更多推荐
使用openssl解密des
发布评论