1 回答
0puppy0
TA贡献24条经验 获得超7个赞
int aes_encrypt(char* in, char* key, char* out)//, int olen)可能会设置buf长度
{
if(!in || !key || !out) return 0;
unsigned char iv[AES_BLOCK_SIZE];//加密的初始化向量
for(int i=0; i<AES_BLOCK_SIZE; ++i)//iv一般设置为全0,可以设置其他,但是加密解密要一样就行
iv[i]=0;
AES_KEY aes;
if(AES_set_encrypt_key((unsigned char*)key, 128, &aes) < 0)
{
return 0;
}
int len=strlen(in);
AES_cbc_encrypt((unsigned char*)in, (unsigned char*)out, len, &aes, iv, AES_ENCRYPT);
return 1;
}
- 1 回答
- 0 关注
- 1097 浏览
添加回答
举报
0/150
提交
取消