The Security services API doesn\'t appear to allow me to compute a hash directly. There are plenty of public domain and liberally licensed versions available, but I\'d rathe
This is what worked for me
func sha256(securityString : String) -> String {
let data = securityString.dataUsingEncoding(NSUTF8StringEncoding)!
var hash = [UInt8](count: Int(CC_SHA256_DIGEST_LENGTH), repeatedValue: 0)
CC_SHA256(data.bytes, CC_LONG(data.length), &hash)
let output = NSMutableString(capacity: Int(CC_SHA1_DIGEST_LENGTH))
for byte in hash {
output.appendFormat("%02x", byte)
}
return output as String
}