CommonCryptoModule 1.0.2

CommonCryptoModule 1.0.2

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Nov 2017
SwiftSwift Version 3.2
SPMSupports SPM

Maintained by Nikita Kukushkin.



CommonCrypto, wrapped in 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

Intallable manually or via Cocoapods:

pod 'CommonCryptoModule', '~> 1.0.1'