菜鸟教程小白 发表于 2022-12-12 23:32:41

ios - iOS 上的 AES128 加密,无需加载整个 NSData


                                            <p><p>使用 Apple Dev 库 (<a href="https://developer.apple.com/library/prerelease/ios/samplecode/CryptoExercise/Listings/Classes_SecKeyWrapper_m.html" rel="noreferrer noopener nofollow">https://developer.apple.com/library/prerelease/ios/samplecode/CryptoExercise/Listings/Classes_SecKeyWrapper_m.html</a>) 中的示例,
特别是这种方法
<code>- (NSData *)doCipher:(NSData *)plainText key:(NSData *)symmetricKey context:(CCOperation)encryptOrDecrypt padding:(CCOptions *)pkcs7 { return nil; }</code> </p>

<p>我可以通过将文件读取到 NSData 然后传递给这个方法来解密和加密文件。</p>

<p>但是,不幸的是,我不得不为此过程使用大量 RAM。</p>

<p>有没有办法直接在磁盘上解密文件而不将文件加载到 NSData?</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>您可以使用单独的 Common Crypto 例程:<code>CCCrytorCreate()</code>、<code>CCCryptorUpdate()</code>、<code>CCCryptorFinal()</code> 和 <code>CCCryptorRelease ()</code> 为每个 block 重复 <code>CCCryptorUpdate()</code>。</p>

<p>参见 Mike Ash 的 <a href="https://www.mikeash.com/pyblog/friday-qa-2012-08-10-a-tour-of-commoncrypto.html" rel="noreferrer noopener nofollow">Friday</a> <em>CommonCrypto 之旅</em>。</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - iOS 上的 AES128 加密,无需加载整个 NSData,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/24480966/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/24480966/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - iOS 上的 AES128 加密,无需加载整个 NSData