another.im-ios/AnotherIM/xmpp/utils/String+Base64.swift

17 lines
427 B
Swift
Raw Normal View History

2024-06-19 15:06:39 +00:00
import Foundation
extension String {
var base64Encoded: String {
// swiftlint:disable:next force_unwrapping
let utf8 = data(using: .utf8)!
let base64 = utf8.base64EncodedString()
return base64
}
var base64Decoded: String {
// swiftlint:disable:next force_unwrapping
let data = Data(base64Encoded: self)!
return String(decoding: data, as: UTF8.self)
}
}