Web/ForgeTrust.Runnable.Web.RazorWire/StringUtils.cs

StringUtils

Type

StringUtils

Provides utility methods for string manipulation, specifically for generating safe identifiers.
Method

ToSafeId(string?, bool)

Produces a safe identifier by replacing disallowed characters with hyphens, collapsing consecutive hyphens, trimming edge hyphens, and defaulting to "id" for null, whitespace, or empty results. Optionally appends a short deterministic 4-character lowercase hex hash (prefixed with a hyphen) derived from the original input to ensure uniqueness.
Method

GetDeterministicHash(string)

Produces a short deterministic 4-character lowercase hexadecimal string derived from the SHA-256 hash of the input.
Returns only the first 4 hex characters (16 bits) of the SHA-256 digest; collisions are possible.