1234567891011121314151617181920212223242526272829 |
- //
- // CommonBase64Tools.swift
- // xingchuangke
- //
- // Created by Virgil on 2019/5/6.
- // Copyright © 2019 Virgil. All rights reserved.
- //
- import UIKit
- class CommonBase64Tools: NSObject {
- class func base64Encoding(str: String) -> String {
- let pData = str.data(using: .utf8)
- let b64 = pData!.base64EncodedString()
- return b64
- }
- class func base64DecodingToString(encodedString: String) -> String {
- let decodedData = Data(base64Encoded: encodedString)
- let decodedString = String(data: decodedData!, encoding: .utf8)!
- return decodedString
- }
- class func base64DecodingToData(encodedString: String) -> Data {
- let decodedData = Data(base64Encoded: encodedString)
- return decodedData!
- }
- }
|