MariusCiocanel / CommonCryptoModule

Module wrapper for CommonCrypto that's importable in Swift.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.2'

About

Module wrapper for CommonCrypto that's importable in Swift.

License:MIT License


Languages

Language:Ruby 57.4%Language:Objective-C 30.6%Language:C 8.6%Language:Swift 3.4%