Apple's cryptography framework. Contains functions for generating commonly-used hashes and cryptographic functions.
Questions tagged [commoncrypto]
200 questions
189
votes
16 answers
Importing CommonCrypto in a Swift framework
How do you import CommonCrypto in a Swift framework for iOS?
I understand how to use CommonCrypto in a Swift app:
You add #import to the bridging header.
However, Swift frameworks don't support bridging headers. The…
![](../../users/profiles/143378.webp)
hpique
- 112,774
- 126
- 328
- 461
38
votes
11 answers
CommonHMAC in Swift
I'm trying to create a HMAC SHA-1 hash of a string in Swift but can't figure out how to interact with the APIs as it doesn't seem to be importing the CommonCrypto framework. I've tried various different forms of "import CommonCrypto" and creating a…
![](../../users/profiles/2705434.webp)
Matt Donnelly
- 417
- 1
- 4
- 6
30
votes
9 answers
AES encryption in swift
I'm trying to implement AES encryption in swift. The encryption decryption for Android and C# is working properly. I need to implement it in swift. It's current code for android and C# is followed by this.
I tried to use
CryptoSwift
Cross platform…
![](../../users/profiles/2594560.webp)
Ankita Shah
- 1,958
- 3
- 20
- 39
20
votes
1 answer
When To Check the "This Application Uses Encryption" Box?
When submitting or updating an app, one question you are faced with is:
Have you added or made changes to encryption features since you last
uploaded a binary for this product?
Image:
My question is, if I use the encryption you get from the…
![](../../users/profiles/590956.webp)
Sam
- 25,752
- 12
- 68
- 97
20
votes
2 answers
Signing and Verifying on iOS using RSA
How to sign and verify some data on iOS with an RSA key (preferably using the system own libcommonCrypto)?
![](../../users/profiles/1037200.webp)
miho
- 10,856
- 6
- 37
- 78
16
votes
3 answers
PBKDF2 using CommonCrypto on iOS
I'm trying to use CommonCrypto to generate keys using PBKDF2 but I can't seem to import CommonCrypto/CommonKeyDerivation.h, I just errors that it is not found.
Any ideas?
edit: I should probably mention I have already added the security framework…
![](../../users/profiles/1064780.webp)
AnthonyM
- 1,005
- 2
- 8
- 20
15
votes
3 answers
Issue using CCCrypt (CommonCrypt) in Swift
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…
![](../../users/profiles/1550223.webp)
eharo2
- 2,115
- 1
- 23
- 37
13
votes
2 answers
Swift Calculate MD5 Checksum for Large Files
I'm working on creating the MD5 Checksum for large video files. I'm currently using the code:
extension NSData {
func MD5() -> NSString {
let digestLength = Int(CC_MD5_DIGEST_LENGTH)
let md5Buffer =…
![](../../users/profiles/4597666.webp)
Mike Walker
- 2,630
- 6
- 26
- 58
13
votes
1 answer
How to use common crypto and/or calculate sha256 in swift 2 & 3
I am trying to make hash a password value according to sha256. I already search this but there is no info about swift 2. This solution did not worked for me
func sha256(data:String) -> String {
let data =…
![](../../users/profiles/4896705.webp)
mesopotamia
- 383
- 1
- 5
- 19
11
votes
2 answers
Swift: How to call CCKeyDerivationPBKDF from Swift
I'm trying to call CCKeyDerivationPBKDF from Swift.
I've imported the required header in my Project-Bridging-Header.h:
#import
(Btw, the bridging header appears to be working correctly for importing other…
![](../../users/profiles/56581.webp)
Daniel
- 8,301
- 4
- 42
- 65
10
votes
4 answers
Data signed on iOS can't be verified in Java
I have some data that I'm signing on iOS with SecKeyRawSign using Elliptic Curve private key. However, verifying that data in Java using Signature.verify() returns false
The data is a random 64 bit integer, split into bytes like so
uint64_t nonce…
![](../../users/profiles/1921348.webp)
mag_zbc
- 5,941
- 14
- 36
- 56
10
votes
3 answers
How can I hash a file on iOS using swift 3?
I have a number of files that will live on a server. Users have the ability to create these kinds of files (plists) on-device which will then upload to said server (CloudKit). I would like to unique them by content (the uniquing methodology should…
![](../../users/profiles/3175163.webp)
iOS Gamer
- 436
- 5
- 8
10
votes
4 answers
CCCrypt decrypting in AES CBC works even without IV
I have a confusing problem, where decrypting a file which was encrypted using CCCrypt's AES-CBC mode with a randomized, 16byte IV produces the exact same output whether I pass in the same correct IV used for encryption or none at all.
What I expect:…
![](../../users/profiles/580730.webp)
Dennis
- 2,164
- 3
- 25
- 32
9
votes
1 answer
lib commonCrypto not available for iOS simulator?
I've been adding libCommonCrypto.dylib to my project to do md5 hash verification. Works all proper on the iPhone (iOS 5.1), but when I try to run it on the simulator, I get this error:
ld: library not found for -lcommonCrypto
clang: error: linker…
![](../../users/profiles/1214761.webp)
Martin Schultz
- 1,631
- 1
- 17
- 24
9
votes
4 answers
Are CC_MD5() and CC_SHA1() available in iOS 4?
I am looking to make use of MD5 or SHA-1 in my iOS application targeted at iOS 4 and later. I use the CC_MD5() and CC_SHA1() functions from CommonCrypto/CommonDigest.h. It seems to work fine on an iPhone running iOS 4.1 and in the iPhone 4.0…
![](../../users/profiles/10223.webp)
GBegen
- 5,979
- 3
- 29
- 51