基于CommonCrypto的Swift语言的加密库:SwiftSSL

jopen 10年前

SwiftSSL 是一个基于CommonCrypto的Swift语言的加密库。

示例代码

SwiftSSL try to do things in swift way, so it doesn't just transfor code from openssl or other lib.

If you wanna digest String or NSData, you can do it just like this:

import SwiftSSL    let plainText: String = "This is plain text."  var digestString = plainText.digest(SwiftSSL.DigestAlgorithm.MD5)

Just that simple!

Wanna sign a message?

import SwiftSSL    let message: String = "This is your message."  let passphrase: String = "Your passphrase"  var signature = message.sign(SwiftSSL.HMACAlgorithm.SHA512, key: passphrase)

SwiftSSL仍然在开发。它已经提供了: