给出以下HashedAuthenticationCode
:
import CryptoKit
let key = SymmetricKey(size: .bits256)
let message = "Hello world!".data(using: .utf8)!
let authenticationCode = HMAC<SHA256>.authenticationCode(for: message, using: key)
print(authenticationCode) // "HMAC with SHA256: c818a1400a9995d5faafbb5d41cc88a6701b5d1a4ded8ac169498319a2597e2a"
如何访问c818a1400a9995d5faafbb5d41cc88a6701b5d1a4ded8ac169498319a2597e2a
值?显然,这必须通过URLSession
进行编码和序列化,但是我认为获取HAC的“代码”部分没有明显的属性!