0
以下代碼對於設備不起作用它不會進入設備的while循環,但它會在模擬器上運行。代碼在iphone上不起作用
int status;
char value[1024] = "abcd";
FILE *fp = popen("openssl enc -aes-128-cbc -k secret -P -md sha1 2>&1", "r");
if (fp == NULL)
exit(1); // handle error
int i=0;
NSString *strAESKey;
while (fgets(value, 1024, fp) != NULL)
{
i++;
if(i==2)
{
strAESKey=[NSString stringWithFormat:@"%s",value];
break;
}
}
status = pclose(fp);
if (status == -1)
{
/* Error reported by pclose() */
}
else
{
/* Use macros described under wait() to inspect `status' in order
to determine success/failure of command executed by popen() */
}
我哪裏錯了?
我們在我們的項目中構建了openssl庫,我們無法生成AES密鑰?請你提供一些參考資料來生成AES密鑰。 – user2050884 2013-02-11 09:52:56
[這是'openssl enc']的源代碼(https://github.com/openssl/openssl/blob/master/apps/enc.c),這是您嘗試運行的命令。 – 2013-02-11 17:09:53