Skip to content
This repository was archived by the owner on Jul 7, 2021. It is now read-only.

Latest commit

 

History

History
35 lines (24 loc) · 1.03 KB

File metadata and controls

35 lines (24 loc) · 1.03 KB

CommonCrypto, wrapped in module

WARNING: iTunesConnect may reject apps that are using this module.

It is currently impossible to import CommonCrypto headers from Swift because they aren't modular. You can find several solutions to this issue on StackOverflow, however they require some effort to implement.

This repo's goal is to provide a modular wrapper to the CommonCrypto, so that it can be imported to Swift without any additional work.

Example

import CommonCryptoModule

extension Data {

    public func md5() -> Data {
        var result = Data(count: Int(CC_MD5_DIGEST_LENGTH))
        _ = result.withUnsafeMutableBytes { resultBytes in
            self.withUnsafeBytes { originBytes in
                CC_MD5(originBytes, CC_LONG(count), resultBytes)
            }
        }
        return result
    }
}

Installation

Can be installed manually or via Cocoapods:

pod 'CommonCryptoModule', '~> 1.0.2'