// // MD5.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 MD5 { /** * Encrypts the given String in to MD5 Hash * * @param value - String that should be converted in to MD5 hash String * @return returns MD5 String */ static func Encrypt(value: String) -> String { let digest = Insecure.MD5.hash(data: value.data(using: .utf8) ?? Data()) return digest.map { String(format: "%02hhx", $0) }.joined() } /** * Encrypts the given byte array in to MD5 Hash * * @param value - byte array that should be converted in to MD5 hash String * @return returns MD5 String */ static func Encrypt(value : Data) -> String { let digest = Insecure.MD5.hash(data: value) return digest.map { String(format: "%02hhx", $0) }.joined() } } }