Check out example codes for "convert string to base64 swift". It will help you in understanding the concepts better.

Code Example 1

import UIKit

extension 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()
    }
}

Learn ReactJs, React Native from akashmittal.com