To md5 in swift?

Need to get MD5 of a string. Written view extension

import Foundation
import CommonCrypto // ERROR : NO SUCH MODULE 'CommonCrypto'

extension Data {
 func hexString() -> String {
 let string = self.map{Int($0).hexString()}.joined()
 return string
}

 func MD5() -> Data {
 var result = Data(count: Int(CC_MD5_DIGEST_LENGTH))
 _ = result.withUnsafeMutableBytes {resultPtr in
 self.withUnsafeBytes {(bytes: UnsafePointer<uint8>) in
 CC_MD5(bytes, CC_LONG(count), resultPtr)
}
}
 return result
}

}

extension String {
 var md5 : String {
 return self.data(using: .utf8)!.MD5().hexString()
}
}</uint8>


Of course, in BridgingHeader it was necessary to add imports. Made:

#import <commoncrypto commoncrypto.h></commoncrypto>

And connected itself the header file:

Objective-C Bridging Header - Parh/To/Header/File.h


The output I get this error:

NO SUCH MODULE 'CommonCrypto'

How to fight? Thank you.
July 2nd 19 at 18:12
1 answer
July 2nd 19 at 18:14
Solution
import is not neededwhen there is #import the header file Objective-C.
Read more about CommonCrypto: iosdeveloperzone.com/2014/10/03/using-commoncrypto...
Themselves could not guess to remove it? And the link this could go.

Find more questions by tags HashingSwift