39 lines
942 B
Swift
39 lines
942 B
Swift
//
|
|
// Base64.swift
|
|
// Befund
|
|
//
|
|
// Created by Irakli Abetschkhrischwili on 29.04.22.
|
|
// Copyright © 2022 MVZ Dr. Stein und Kollegen. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
import CryptoKit
|
|
|
|
extension Core.Security
|
|
{
|
|
public class Base64
|
|
{
|
|
/**
|
|
* Converts byte array to the base64 String
|
|
*
|
|
* @param data - byte array that should be converted in to base64 string
|
|
* @return returns base64 String
|
|
*/
|
|
static func ToBase64String(data: Data) -> String
|
|
{
|
|
return data.base64EncodedString()
|
|
}
|
|
|
|
/**
|
|
* Converts base64 string in to byte array
|
|
*
|
|
* @param base64 - base64 String, that should be converted in to byte array
|
|
* @return returns byte array
|
|
*/
|
|
static func FromBase64String(base64: String) -> Data?
|
|
{
|
|
return Data(base64Encoded: base64)
|
|
}
|
|
}
|
|
}
|