|
@@ -23,7 +23,7 @@
|
|
|
|
|
|
import Foundation
|
|
|
import UIKit
|
|
|
-import CommonCrypto
|
|
|
+import CryptoKit
|
|
|
|
|
|
extension String {
|
|
|
|
|
@@ -50,6 +50,14 @@ extension String {
|
|
|
return String(format: "%02d:%02d:%02d", hour, min, sec)
|
|
|
}
|
|
|
|
|
|
+ func md5() -> String {
|
|
|
+ let digest = Insecure.MD5.hash(data: self.data(using: .utf8) ?? Data())
|
|
|
+ return digest.map {
|
|
|
+ String(format: "%02hhx", $0)
|
|
|
+ }.joined()
|
|
|
+ }
|
|
|
+
|
|
|
+ /* DEPRECATED iOS 13
|
|
|
func md5() -> String {
|
|
|
// https://stackoverflow.com/a/32166735/9506784
|
|
|
|
|
@@ -69,6 +77,7 @@ extension String {
|
|
|
|
|
|
return digestData.map { String(format: "%02hhx", $0) }.joined()
|
|
|
}
|
|
|
+ */
|
|
|
|
|
|
var urlEncoded: String? {
|
|
|
// + for historical reason, most web servers treat + as a replacement of whitespace
|