0puppy0
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;}