0

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>

here is the screen shot of errors

Can you also talk about bridging header file and adding this import line if they are necessary.

mannyCalavera
  • 593
  • 1
  • 4
  • 23
  • That is *very* old Swift. Have a look at https://stackoverflow.com/q/32163848/1187415 for more up-to-date code. – Martin R May 17 '18 at 11:07
  • @MartinR yes, but i have already wrote that : 'below code was working with old version but it does not work with swift version 4.1'. I thought you were showing me a solution. – mannyCalavera May 17 '18 at 13:23
  • ... and I pointed you to code which does work in Swift 4.1. – Martin R May 17 '18 at 13:27

0 Answers0