1
根據關於http://forums.macrumors.com/showthread.php?t=551476的討論,以下代碼可用於RSA加密。密鑰的數據類型(「public」)是SecKeyRef。儘管如此,我不會使用鑰匙串,因爲我只對密鑰公開且不是祕密的加密感興趣。那麼甚至可以使用加密API呢?我目前的想法是隻從我的公鑰構造SecKeyRef結構並使用API。不過,我不知道結構是如何聲明的。有人知道嗎?你認爲我的方法會起作用嗎?iPhone上的RSA加密
uint8_t *pPlainText = (uint8_t*) "This is a test";
uint8_t aCipherText[1024];
size_t iCipherLength = 1024;
status = SecKeyEncrypt(public,
kSecPaddingNone,
pPlainText,
strlen((char*) pPlainText) + 1,
aCipherText,
&iCipherLength);