在使用CryptoPP库时,大多key和iv都是CryptoPP::SecByteBlock这种类型,有时候想用key和iv做一些事情,我习惯用unsigned char类型,方便一些。
转换方法如下:
//这里就是举个例子,只有一些必要的代码片段:
using namespace std;
using namespace CryptoPP;
SecByteBlock key;
string s = string(key.begin(), key.end());
unsigned char out[32];
memcpy(out, s.c_str(), s.length());
//这样就从key转为了out