在Crypto ++中将十六进制字符串转换为字节

M.A*_*M.A 3 c++ encoding cryptography crypto++

我有十六进制的字符串,我需要转换为const byte*.我正在使用Crypto ++进行散列,它需要密钥才能使用const byte*任何方法我可以将十六进制字符串转换为const byte*使用任何Crypto ++库,或者我是否需要自己编写?

Maa*_*wes 5

HexDecoderCrypto ++中有一个类.

你需要提供这个字符.似乎Crypto ++没有直接区分字符和字节.因此varren提供的以下代码行将起作用:

StringSource ss(source, true, new HexEncoder(new StringSink(destination)));
const byte* result = (const byte*) destination.data();
Run Code Online (Sandbox Code Playgroud)