Below code was working with old versions but it does not work with swift 4.1 version:
func md5(#string: String) -> NSData {
var digest = NSMutableData(length: Int(CC_MD5_DIGEST_LENGTH))!
if let data :NSData = string.dataUsingEncoding(NSUTF8StringEncoding) {
CC_MD5(data.bytes, CC_LONG(data.length),
UnsafeMutablePointer<UInt8>(digest.mutableBytes))
}
return digest
}
//Test:
let digest = md5(string:"Here is the test string")
println("digest: \(digest)")
and should i do any other issues like bridging header file or adding this line below:
#import <CommonCrypto/CommonCrypto.h>
Can you also talk about bridging header file and adding this import line if they are necessary.