How to hash NSString with SHA1 in Swift?
Your Objective-C code (using a NSString category) can be directly translated to Swift (using a String extension). First you have to create a “bridging header” and add #import <CommonCrypto/CommonCrypto.h> Then: extension String { func sha1() -> String { let data = self.dataUsingEncoding(NSUTF8StringEncoding)! var digest = [UInt8](count:Int(CC_SHA1_DIGEST_LENGTH), repeatedValue: 0) CC_SHA1(data.bytes, CC_LONG(data.length), &digest) let output = NSMutableString(capacity: … Read more