DigestUtils

JSON canonicalization and digest computation utilities.

Provides optimized implementations for JSON canonicalization and SHA-256 digest computation with multibase encoding (base58btc).

Performance Optimizations:

  • Cached JSON instances for reuse

  • Optimized canonicalization algorithm

  • Thread-safe digest computation

Properties

Link copied to clipboard

The current cache size. Useful for monitoring cache usage.

Link copied to clipboard

Whether digest caching is enabled. Set to false to disable caching (useful for memory-constrained environments).

Link copied to clipboard

Maximum number of entries in the digest cache. When this limit is reached, least recently used entries are evicted.

Functions

Link copied to clipboard
fun canonicalizeJson(jsonString: String): String

Canonicalizes a JSON string by parsing and re-serializing with stable key ordering.

fun canonicalizeJson(element: JsonElement): String

Canonicalizes a JSON element by sorting keys lexicographically.

Link copied to clipboard

Clears the digest cache. Useful for memory management or testing.

Link copied to clipboard

Computes SHA-256 digest of a string with multibase encoding (base58btc).

fun sha256DigestMultibase(element: JsonElement): String

Computes SHA-256 digest of a JSON element with multibase encoding (base58btc).