gradum-kit - v0.1.0
    Preparing search index...

    Function hashBySize

    • Function

      hashBySize

      Parameters

      • input: string

        The string to hash.

      • Optionalchars: number = 12

        How many characters the result should be.

      Returns Promise<string>

      The truncated URL-safe digest.

      Hash a string with SHA-256 and render it as a short, URL-safe string of the requested length. The alphabet is base64 with + and / swapped for - and _ and the padding dropped, so the result is safe in URLs and identifiers. Shorter lengths raise the chance of collisions.