- 论坛徽章:
- 0
|
使用C语言调用openssl进行des加密,cbc模式,但加密出来的结果和php,c#,python等加密的结果不一致,请问,有人遇到类似情况吗?
谢谢!
c测试函数如下:
#include <stdio.h>
#include <string.h>
#include <openssl/des.h>
int main()
{
int i = 0;
des_cblock key1;
char input[8];
des_cblock ivec;
des_key_schedule schedule1;
unsigned char output[32] = { 0 };
DES_string_to_key("password", &key1);
DES_set_key_checked(&key1, &schedule1);
strncpy(input, "hehehehe", ;
/**
* ncbc encrypt
*/
memset(ivec, 0, sizeof(ivec));
DES_ncbc_encrypt(input, output, sizeof(input), &schedule1, &ivec, DES_ENCRYPT);
printf("use key1 ncbc-encrypt 'hehehehe' output is: " ;
for(i = 0; i < sizeof(input); i ++)
{
printf("%02x", output);
}
printf("\n\n" ;
return 0;
} |
|