-
constantTimeEqual( a: Uint8Array<ArrayBufferLike> | null | undefined, b: Uint8Array<ArrayBufferLike> | null | undefined,): boolean
参数
- a: Uint8Array<ArrayBufferLike> | null | undefined
- b: Uint8Array<ArrayBufferLike> | null | undefined
返回 boolean
内容相同返回 true
尽量避免按内容提前返回的字节数组比较。
用途:MAC / AEAD tag / HMAC / SM2 C3 哈希等敏感值比较。普通
===或循环早返回会随首个不匹配位置变化执行时间。JavaScript/JIT 运行时不提供 严格恒时保证,本函数只避免显式按内容提前退出。语义(与 Java
cn.gmkit.core.Bytes.constantTimeEquals对齐):