使用卡上对称密钥文件中的密钥对输入的数据进行加/解密。

参数
[in] hcontexthandle
一个已经成功打开的设备的句柄。
[in] puchin
要加/解密的数据。
[in] ulinlen
要加密的数据长度,为16的倍数。
[out] puchout
输出的数据。
[out] puloutlen
输出数据的长度。
[in] ulflag
定义如下:
esf_encrypt:进行加密操作。
esf_decrypt:进行解密操作。
要求
esfp_opendev
返回值
esf_success:成功
esf_rv_parameter_error:参数错误,函数调用的参数可能不符合要求
esf_rv_not_find_file_error:文件或目录未找到
其它:见“api返回码说明”。
示例代码
esf_handle hcontexthandle = null;
esf_rv irv;
unsigned char uchbuf[400];
unsigned long ullen = 0;
printf("\n原文:\n");
for(i=0; i[32; i++)
{
uchbuf[i] = i;
printf("%x ", uchbuf[i]);
}
irv = esfp_encrypt(hcontexthandle, uchbuf, 32, uchbuf, &ullen, esf_encrypt);
if(irv != esf_rv_success)
{
goto encrypt_error;
}
printf("\n加密后的数据:\n");
for(i=0; i[32; i++)
{
printf("%x ", uchbuf[i]);
}
return irv;
参见
esfp_createfile,esfp_writefile