Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where can I get CommonCrypto / CommonCrypto file from?

I have a problem with importing CommonCrypto/CommonCrypto or CommonCrypto/CommonDigest. I need a SHA256 for my Swift code.

I found CommonCrypto github site in Cocoapods.

https://github.com/AlanQuatermain/aqtoolkit

So I have downloaded the file from above. But I'm getting errors about ARC (I have added Bridging-Header like other tutorials do.)
The header file's name is NSData+CommonCrypto.h and NSData+CommonCrypto.m.
It's not a CommonCrypto/CommonCrypto or CommonCrypto/CommonDigest Where can I download and get the exact file CommonCrypto for SHA256?

like image 919
kimpro Avatar asked Mar 12 '23 14:03

kimpro


1 Answers

No additional files are required. You need a bridging header first of all, which you already have but for those who don't the easiest way to achieve this is to add an Objective-C file to your project and to accept when it offers to create a bridging header. You can then either import the whole of CommonCrypto (thanks @zaph - see comments) to the bridging header:

#import <CommonCrypto/CommonCrypto.h>

Or the constituent parts:

#import <CommonCrypto/CommonCryptor.h>
#import <CommonCrypto/CommonDigest.h>
#import <CommonCrypto/CommonHMAC.h>
#import <CommonCrypto/CommonKeyDerivation.h>
#import <CommonCrypto/CommonSymmetricKeywrap.h>

You can now use CommonCrypto in Swift. For example code see here.

Edit

In Xcode 10 a bridging header is no longer required to import CommonCrypto in Swift. You can simply use:

import CommonCrypto
like image 178
sketchyTech Avatar answered Mar 20 '23 08:03

sketchyTech