commoncrypto

Importing CommonCrypto in a Swift framework

。_饼干妹妹 提交于 2019-11-26 05:47:55
问题 How do you import CommonCrypto in a Swift framework for iOS? I understand how to use CommonCrypto in a Swift app: You add #import <CommonCrypto/CommonCrypto.h> to the bridging header. However, Swift frameworks don\'t support bridging headers. The documentation says: You can import external frameworks that have a pure Objective-C codebase, a pure Swift codebase, or a mixed-language codebase. The process for importing an external framework is the same whether the framework is written in a

Issue using CCCrypt (CommonCrypt) in Swift

戏子无情 提交于 2019-11-26 04:25:53
问题 I am porting a working Objective-C Category (NSData+AESCrypt.m) to Swift and I have found an issue working with the pointers. The code for the encrypting part in Swift compiles correctly, but generates a runtime EXEC_BAD_ACCES error. The code I have so far is (I tried to dissect the code as much as possible) : let key = \"123456789012345678901234567890120\" let keyLength = UInt(kCCKeySizeAES256 + 1) let keyPointer = strdup(key) // Convert key to <UnsafeMutablePointer<Int8> let message = \"Don