lthn

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 24, 2026 License: EUPL-1.2 Imports: 2 Imported by: 0

Documentation

Overview

Package lthn implements the LTHN quasi-salted hash algorithm (RFC-0004).

LTHN produces deterministic, verifiable hashes without requiring separate salt storage. The salt is derived from the input itself through:

  1. Reversing the input string
  2. Applying "leet speak" style character substitutions

The final hash is: SHA256(input || derived_salt)

This is suitable for content identifiers, cache keys, and deduplication. NOT suitable for password hashing - use bcrypt, Argon2, or scrypt instead.

Example:

hash := lthn.Hash("hello")
valid := lthn.Verify("hello", hash)  // true

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetKeyMap

func GetKeyMap() map[rune]rune

GetKeyMap returns the current character substitution map.

func Hash

func Hash(input string) string

Hash computes the LTHN hash of the input string.

The algorithm:

  1. Derive a quasi-salt by reversing the input and applying character substitutions
  2. Concatenate: input + salt
  3. Compute SHA-256 of the concatenated string
  4. Return the hex-encoded digest (64 characters, lowercase)

The same input always produces the same hash, enabling verification without storing a separate salt value.

func SetKeyMap

func SetKeyMap(newKeyMap map[rune]rune)

SetKeyMap replaces the default character substitution map. Use this to customize the quasi-salt derivation for specific applications. Changes affect all subsequent Hash and Verify calls.

func Verify

func Verify(input string, hash string) bool

Verify checks if an input string produces the given hash. Returns true if Hash(input) equals the provided hash value. Uses direct string comparison - for security-critical applications, consider using constant-time comparison.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL