UNPKG

@synet/core

Version:

Core cryptographic and identity primitives for Synet agents.

14 lines (10 loc) 409 B
import * as crypto from "node:crypto"; export function sha256Hex(input: string | Buffer): string { return crypto.createHash("sha256").update(input).digest("hex"); } export function sha256Base64(input: string | Buffer): string { return crypto.createHash("sha256").update(input).digest("base64"); } export function hashToAgentId(publicKey: string): string { return sha256Hex(publicKey).slice(0, 16); }