Commit 2b5ea931 by Sarkizz

添加base64转换方法

parent fe5601da
......@@ -9,6 +9,7 @@
import Foundation
import CommonCrypto
// MARK: - MD5
extension Data {
public var md5: String {
let hash = self.withUnsafeBytes { (bytes: UnsafeRawBufferPointer) -> [UInt8] in
......@@ -19,3 +20,10 @@ extension Data {
return hash.map { String(format: "%02x", $0) }.joined()
}
}
// MARK: - base64
extension Data {
public var base64String: String? {
return base64EncodedString(options: .init(rawValue: 0))
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment