sdk-ci / test (push) Failing after 8s
- 自主仓 git.wxccs.org/EntitleForge/EntitleForge 拆分(协议实现单一归属: license/crypto/ulid 随 SDK 迁出,服务端反向依赖本仓) - sdk:Client 三模式(文件/远程/代理)、GRACE 状态机、查询 API(6.6ns/0 alloc) - license:三段式编解码与严格解析;crypto:Ed25519 信任链 + Proxy 受约束证书 - 零第三方依赖(CI 有依赖闭包断言红线);go.mod 零 require - CI:Gitea Actions(test + 零依赖断言 + 三平台交叉编译冒烟)
22 lines
661 B
Go
22 lines
661 B
Go
package license
|
|
|
|
import (
|
|
"crypto/sha256"
|
|
"encoding/hex"
|
|
"encoding/json"
|
|
)
|
|
|
|
// EntitlementsHash 计算授权集合的确定性摘要,用于心跳变更检测。
|
|
// 序列化依赖 encoding/json 的 map 键字典序输出(确定性),Entitlement
|
|
// 的 MarshalJSON 亦为固定字段序,两侧(服务端/SDK)算法一致。
|
|
func EntitlementsHash(ents map[string]Entitlement) string {
|
|
b, err := json.Marshal(ents)
|
|
if err != nil {
|
|
// map[string]Entitlement 不存在 marshal 失败路径;防御性返回空摘要
|
|
sum := sha256.Sum256(nil)
|
|
return hex.EncodeToString(sum[:])
|
|
}
|
|
sum := sha256.Sum256(b)
|
|
return hex.EncodeToString(sum[:])
|
|
}
|