12 lines
293 B
Swift
12 lines
293 B
Swift
|
|
import Foundation
|
||
|
|
import CryptoKit
|
||
|
|
|
||
|
|
enum HashUtil {
|
||
|
|
static func sha256Hex(prefix: String, body: Data) -> String {
|
||
|
|
var input = Data(prefix.utf8)
|
||
|
|
input.append(body)
|
||
|
|
let h = SHA256.hash(data: input)
|
||
|
|
return h.map { String(format: "%02x", $0) }.joined()
|
||
|
|
}
|
||
|
|
}
|