Encode a value to deterministic CBOR bytes. Accepts anything cbor() accepts; equal values always produce identical bytes (dCBOR determinism).
cbor()
encodeCbor({ a: 1 }); // Uint8Array [0xa1, 0x61, 0x61, 0x01]bytesToHex(encodeCbor("Hello")); // "6548656c6c6f" Copy
encodeCbor({ a: 1 }); // Uint8Array [0xa1, 0x61, 0x61, 0x01]bytesToHex(encodeCbor("Hello")); // "6548656c6c6f"
Whatever cbor(value) throws for unsupported inputs (OutOfRange, Custom).
cbor(value)
OutOfRange
Custom
The decoder's canonicality check re-encodes every decoded value through this function, so it is wire-critical.
Encode a value to deterministic CBOR bytes. Accepts anything
cbor()accepts; equal values always produce identical bytes (dCBOR determinism).