# 🦆 waddling-errors-hash
WDP-compliant xxHash3 computation for diagnostic codes.
[](https://crates.io/crates/waddling-errors-hash)
[](https://docs.rs/waddling-errors-hash)
---
## What It Does
Converts error codes to compact 5-character hashes per [WDP Part 5](https://gitlab.com/AshutoshMahala/wdp-specs/-/blob/main/5-COMPACT-IDS.md).
```rust
use waddling_errors_hash::compute_wdp_hash;
let hash = compute_wdp_hash("E.Auth.Token.001");
// Returns 5-char base62 hash, e.g., "V6a0B"
// Case-insensitive (WDP normalization):
assert_eq!(
compute_wdp_hash("E.Auth.Token.001"),
compute_wdp_hash("e.auth.token.001")
);
```
---
## Installation
```toml
[dependencies]
waddling-errors-hash = "0.7"
```
---
## API
### WDP-Conformant (Recommended)
```rust
use waddling_errors_hash::{
compute_wdp_hash, // Hash error code
compute_wdp_namespace_hash, // Hash namespace
compute_wdp_full_id, // "ns_hash-code_hash"
};
let code_hash = compute_wdp_hash("E.Auth.Token.001"); // "V6a0B"
let ns_hash = compute_wdp_namespace_hash("auth_lib"); // "05o5h"
let full_id = compute_wdp_full_id("auth_lib", "E.Auth.Token.001"); // "05o5h-V6a0B"
```
### Custom Seed
```rust
use waddling_errors_hash::{compute_hash_with_config, HashConfig};
let config = HashConfig::with_seed(0x1234567890ABCDEF);
let hash = compute_hash_with_config("E.Auth.Token.001", &config);
```
---
## WDP Seeds
| Error codes | `"wdp-v1"` | `0x000031762D706477` |
| Namespaces | `"wdpns-v1"` | `0x31762D736E706477` |
---
## Cross-Language
Same algorithm works in Python, JS, Go, etc:
```python
import xxhash
WDP_SEED = 0x000031762D706477
hash_value = xxhash.xxh3_64(input_bytes, seed=WDP_SEED)
```
---
## Security Note
xxHash3 is NOT cryptographically secure. It's designed for speed and distribution quality. Use TLS/JWT for security requirements.
---
## Documentation
- [WDP Part 5: Compact IDs](https://gitlab.com/AshutoshMahala/wdp-specs/-/blob/main/5-COMPACT-IDS.md)
- [WDP Part 7: Namespaces](https://gitlab.com/AshutoshMahala/wdp-specs/-/blob/main/7-NAMESPACES.md)
- [API Reference](https://docs.rs/waddling-errors-hash)
---
## License
MIT or Apache-2.0.