iOS Base64 encoding with Swift 3 发表于 2017-06-08 | 分类于 iOS 12345678910111213141516import UIKitextension String { func fromBase64() -> String? { guard let data = Data(base64Encoded: self) else { return nil } return String(data: data, encoding: .utf8) } func toBase64() -> String { return Data(self.utf8).base64EncodedString() }}