Answer the question
In order to leave comments, you need to log in
Get md5 in swift?
You need to get the MD5 strings. View extension written
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()
}
}
Objective-C Bridging Header - Parh/To/Header/File.h
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question