基于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仍然在开发。它已经提供了:
- Crypto
- Digest
- MD2
- MD4
- MD5
- SHA1
- SHA224
- SHA256
- SHA384
- SHA512
- HMAC
- MD5
- SHA1
- SHA224
- SHA256
- SHA384
- SHA512 </ul> </li> </ul> </li> </ul>
- Digest