Answer the question
In order to leave comments, you need to log in
how to write openssl_decrypt in golang?
actual php code:
if(in_array('aes-256-cbc', openssl_get_cipher_methods())){
if(openssl_decrypt(hex2bin($passHashArray[1]), 'aes-256-cbc', $key, OPENSSL_RAW_DATA, $iv)){
echo 'correct';
}else{
echo 'decrypt failed';
}
}
result, err := decrypt(cipherTextDecoded, encKeyDecoded, ivDecoded)
if err != nil {
log.Printf("error hex decode string password hash array: %s", err)
}
log.Println(result)
func decrypt(cipherTextDecoded []byte, encKeyDecoded []byte, ivDecoded []byte) (string, error) {
block, err := aes.NewCipher(encKeyDecoded)
if err != nil {
return "", err
}
mode := cipher.NewCBCDecrypter(block, ivDecoded)
mode.CryptBlocks(cipherTextDecoded, cipherTextDecoded)
return string(cipherTextDecoded), nil
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question