swift - 如何访问 HashedAuthenticationCode 的代码(作为字符串)?
问题描述
鉴于以下情况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
值?最终,这必须通过 a 进行编码和序列化URLSession
,但我看不到获取 HAC 的“代码”部分的明显属性!
解决方案
推荐阅读
- php - PHP GD - 使用 imagettftext() 时图像损坏
- javascript - 测试是否使用 Jest 调用了实际函数
- java - 组合或聚合特定示例
- azure-api-management - 正文未通过 Azure API 管理发送
- java - 使用 Stream API 生成平面树
- python - 如何从数据框的多列中获取最近的日期?
- php - Symfony 4 错误:服务中未使用的绑定“$projectDir”
- django - Django (DRF) 多对多字段选择/限制
- flutter - Flutter 基础状态管理
- go - S3 存储桶命名策略问题并尝试将 SDK 生成的请求发送到实现 S3 API 的 API