# ContentHasher

- File ID: file:13kvr59:contenthasher-cs
- Path: NexusReader.Infrastructure/Helpers/ContentHasher.cs
- Role: service
- Layer: infrastructure

## Purpose

Provides deterministic normalization and SHA-256 hashing for content strings used across the infrastructure (e.g., content fingerprinting / cache keys).

## Key Details

Deterministic normalization (trim, collapse whitespace, lower-case) + SHA-256 and lower-case hex output. Guard-clauses return empty string for null/whitespace inputs.

## Symbols

- ContentHasher: Provides deterministic normalization and SHA-256 hashing for content strings used across the infrastructure (e.g., content fingerprinting / cache keys).
- ComputeHash(): Normalize the provided string and return its SHA-256 hash as a lower-case hex string; returns empty string for null/whitespace input.
- Normalize(): Produce a deterministic normalized version of the input by trimming, collapsing whitespace to single spaces, and lower-casing; returns empty for null/whitespace input.
- ContentHasher: Static helper class exposing normalization and hashing utilities for content.

## Dependencies

- No resolved dependencies.

## Calls

- No resolved calls.

## Unresolved References

- call-target: self
- interaction-target: var hashBytes = SHA256.HashData(inputBytes) (framework API)

## Coverage

- Symbols: 4
- Executable symbols: 2
- Executable symbols with control flow: 2
- Grounded edges: 4
- Unresolved references: 2
- Control-flow fragments: 2
- Unresolved jumps: 0
- Unsupported constructs: 0
- Control-flow coverage: 100%
- Required diagrams: 2
- Generated diagrams: 4

## Control Flow Fragments

- ComputeHash: 18 nodes, 19 edges, 1 jumps, 0 unsupported constructs
- Normalize: 14 nodes, 15 edges, 0 jumps, 0 unsupported constructs

## Diagrams

### ContentHasher Neighborhood

```mermaid
flowchart LR
    class_lvxelt_contenthasher("ContentHasher")
    file_13kvr59_contenthasher_cs("ContentHasher")
    method_1e84qm4_normalize[["Normalize()"]]
    method_pslukv_computehash[["ComputeHash()"]]
    type_7fsbyq_contenthasher[/"ContentHasher"/]
```

### ContentHasher Execution Overview

```mermaid
flowchart TD
    class_lvxelt_contenthasher("ContentHasher")
    method_1e84qm4_normalize[["Normalize()"]]
    method_pslukv_computehash[["ComputeHash()"]]
    unresolved_unresolved_7qxs61_interaction_target{"Unresolved: var hashBytes = SHA256.HashData(inputBytes) (framework API)"}
    unresolved_unresolved_p2lu8n_call_target{"Unresolved: Normalize"}
    class_lvxelt_contenthasher -->|contains| method_1e84qm4_normalize
    class_lvxelt_contenthasher -->|contains| method_pslukv_computehash
    class_lvxelt_contenthasher -->|unresolved interaction| unresolved_unresolved_7qxs61_interaction_target
    method_pslukv_computehash -->|unresolved call| unresolved_unresolved_p2lu8n_call_target
```

### ComputeHash() Control Flow

```mermaid
flowchart TD
    method_pslukv_computehash__call_16_Normalize[["Normalize"]]
    method_pslukv_computehash__action_11_computehash_branch_11_0__condition{"string.IsNullOrWhiteSpace(input)"}
    method_pslukv_computehash__action_11_computehash_branch_11_0__false("false")
    method_pslukv_computehash__action_11_computehash_branch_11_0__merge("merge")
    method_pslukv_computehash__action_11_computehash_branch_11_0__true("true")
    method_pslukv_computehash__action_11_guard_clause_11__condition{"string.IsNullOrWhiteSpace(input)"}
    method_pslukv_computehash__action_11_guard_clause_11__false("continue")
    method_pslukv_computehash__action_11_guard_clause_11__merge("merge")
    method_pslukv_computehash__action_11_guard_clause_11__true("return-empty")
    method_pslukv_computehash__action_16_orchestration_16__linear("Normalization call")
    method_pslukv_computehash__action_18_transform_18__linear("UTF-8 encoding")
    method_pslukv_computehash__action_21_transform_21__linear("Hex conversion and normalization")
    method_pslukv_computehash__entry(["ComputeHash entry"])
    method_pslukv_computehash__action_19_external_call_19__linear("SHA-256 hash computation")
    method_pslukv_computehash__action_13_computehash_return_13_1__return(["Returns result"])
    method_pslukv_computehash__action_21_computehash_return_21_2__return(["Returns result"])
    method_pslukv_computehash__action_21_return_21__return(["Returns hash string"])
    method_pslukv_computehash__implicit_return(["return"])
    method_pslukv_computehash__action_11_computehash_branch_11_0__condition -->|false| method_pslukv_computehash__action_11_computehash_branch_11_0__false
    method_pslukv_computehash__action_11_computehash_branch_11_0__condition -->|true| method_pslukv_computehash__action_11_computehash_branch_11_0__true
    method_pslukv_computehash__action_11_computehash_branch_11_0__false -->|next| method_pslukv_computehash__action_11_computehash_branch_11_0__merge
    method_pslukv_computehash__action_11_computehash_branch_11_0__merge -->|return| method_pslukv_computehash__action_13_computehash_return_13_1__return
    method_pslukv_computehash__action_11_computehash_branch_11_0__true -->|next| method_pslukv_computehash__action_11_computehash_branch_11_0__merge
    method_pslukv_computehash__action_11_guard_clause_11__condition -->|continue| method_pslukv_computehash__action_11_guard_clause_11__false
    method_pslukv_computehash__action_11_guard_clause_11__condition -->|return-empty| method_pslukv_computehash__action_11_guard_clause_11__true
    method_pslukv_computehash__action_11_guard_clause_11__false -->|next| method_pslukv_computehash__action_11_guard_clause_11__merge
    method_pslukv_computehash__action_11_guard_clause_11__merge -->|next| method_pslukv_computehash__action_11_computehash_branch_11_0__condition
    method_pslukv_computehash__action_11_guard_clause_11__true -->|next| method_pslukv_computehash__action_11_guard_clause_11__merge
    method_pslukv_computehash__action_13_computehash_return_13_1__return -->|next| method_pslukv_computehash__action_16_orchestration_16__linear
    method_pslukv_computehash__action_16_orchestration_16__linear -->|input string to normalize| method_pslukv_computehash__call_16_Normalize
    method_pslukv_computehash__action_18_transform_18__linear -->|next| method_pslukv_computehash__action_19_external_call_19__linear
    method_pslukv_computehash__action_19_external_call_19__linear -->|return| method_pslukv_computehash__action_21_computehash_return_21_2__return
    method_pslukv_computehash__action_21_computehash_return_21_2__return -->|return| method_pslukv_computehash__action_21_return_21__return
    method_pslukv_computehash__action_21_return_21__return -->|next| method_pslukv_computehash__action_21_transform_21__linear
    method_pslukv_computehash__action_21_transform_21__linear -->|return| method_pslukv_computehash__implicit_return
    method_pslukv_computehash__call_16_Normalize -->|next| method_pslukv_computehash__action_18_transform_18__linear
    method_pslukv_computehash__entry -->|next| method_pslukv_computehash__action_11_guard_clause_11__condition
```

### Normalize() Control Flow

```mermaid
flowchart TD
    method_1e84qm4_normalize__action_26_guard_clause_26__condition{"string.IsNullOrWhiteSpace(input)"}
    method_1e84qm4_normalize__action_26_guard_clause_26__false("continue")
    method_1e84qm4_normalize__action_26_guard_clause_26__merge("merge")
    method_1e84qm4_normalize__action_26_guard_clause_26__true("return-empty")
    method_1e84qm4_normalize__action_26_normalize_branch_26_0__condition{"string.IsNullOrWhiteSpace(input)"}
    method_1e84qm4_normalize__action_26_normalize_branch_26_0__false("false")
    method_1e84qm4_normalize__action_26_normalize_branch_26_0__merge("merge")
    method_1e84qm4_normalize__action_26_normalize_branch_26_0__true("true")
    method_1e84qm4_normalize__action_31_transform_31__linear("Trim and collapse whitespace")
    method_1e84qm4_normalize__action_34_transform_34__linear("Case normalization")
    method_1e84qm4_normalize__entry(["Normalize entry"])
    method_1e84qm4_normalize__action_28_normalize_return_28_1__return(["Returns result"])
    method_1e84qm4_normalize__action_35_normalize_return_35_2__return(["Returns result"])
    method_1e84qm4_normalize__action_35_return_35__return(["Returns normalized string"])
    method_1e84qm4_normalize__action_26_guard_clause_26__condition -->|continue| method_1e84qm4_normalize__action_26_guard_clause_26__false
    method_1e84qm4_normalize__action_26_guard_clause_26__condition -->|return-empty| method_1e84qm4_normalize__action_26_guard_clause_26__true
    method_1e84qm4_normalize__action_26_guard_clause_26__false -->|next| method_1e84qm4_normalize__action_26_guard_clause_26__merge
    method_1e84qm4_normalize__action_26_guard_clause_26__merge -->|next| method_1e84qm4_normalize__action_26_normalize_branch_26_0__condition
    method_1e84qm4_normalize__action_26_guard_clause_26__true -->|next| method_1e84qm4_normalize__action_26_guard_clause_26__merge
    method_1e84qm4_normalize__action_26_normalize_branch_26_0__condition -->|false| method_1e84qm4_normalize__action_26_normalize_branch_26_0__false
    method_1e84qm4_normalize__action_26_normalize_branch_26_0__condition -->|true| method_1e84qm4_normalize__action_26_normalize_branch_26_0__true
    method_1e84qm4_normalize__action_26_normalize_branch_26_0__false -->|next| method_1e84qm4_normalize__action_26_normalize_branch_26_0__merge
    method_1e84qm4_normalize__action_26_normalize_branch_26_0__merge -->|return| method_1e84qm4_normalize__action_28_normalize_return_28_1__return
    method_1e84qm4_normalize__action_26_normalize_branch_26_0__true -->|next| method_1e84qm4_normalize__action_26_normalize_branch_26_0__merge
    method_1e84qm4_normalize__action_28_normalize_return_28_1__return -->|next| method_1e84qm4_normalize__action_31_transform_31__linear
    method_1e84qm4_normalize__action_31_transform_31__linear -->|next| method_1e84qm4_normalize__action_34_transform_34__linear
    method_1e84qm4_normalize__action_34_transform_34__linear -->|return| method_1e84qm4_normalize__action_35_normalize_return_35_2__return
    method_1e84qm4_normalize__action_35_normalize_return_35_2__return -->|return| method_1e84qm4_normalize__action_35_return_35__return
    method_1e84qm4_normalize__entry -->|next| method_1e84qm4_normalize__action_26_guard_clause_26__condition
```

## Diagram Validation

- Status: pass
