AES/RSA/MD2/MD5/SHA1/SHA128/SHA384/SHA512 in Swift
可以參考github: https://github.com/adow/SecrecySwift
https://github.com/SwiftP2P/SwiftSSL
swift實(shí)現(xiàn)sha1加密算法,需要現(xiàn)在beidge-header文件中添加下述語句
// sha1
#import <CommonCrypto/CommonHMAC.h>
sha1
import UIKit
extension String{
func sha1() -> String{
let data = self.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: true)!
var digest = [UInt8](count:Int(CC_SHA1_DIGEST_LENGTH),repeatedValue:0)
CC_SHA1(data.bytes, CC_LONG(data.length), &digest)
let output = NSMutableString(capacity: Int(CC_SHA1_DIGEST_LENGTH))
for byte in digest{
output.appendFormat("%02x", byte)
}
return output as String
}
}