docs: translate CLAUDE.md to German

Translate project documentation from English to German for better accessibility.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-13 20:05:36 +00:00
parent eb552a9164
commit 5cf4799054

130
CLAUDE.md
View File

@@ -1,104 +1,104 @@
# CLAUDE.md # CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. Diese Datei bietet Anleitungen für Claude Code (claude.ai/code) bei der Arbeit mit Code in diesem Repository.
## Project Overview ## Projektübersicht
This is a Python PBKDF2 password hashing utility with two implementations: Dies ist ein Python PBKDF2 Passwort-Hashing-Tool mit zwei Implementierungen:
- `salt.py`: Reference implementation with CLI that supports both `hash` and `verify` subcommands, plus a shortcut where running `python3 salt.py <password>` automatically invokes the hash command - `salt.py`: Referenzimplementierung mit CLI, die sowohl `hash` als auch `verify` Unterbefehle unterstützt, plus eine Abkürzung, bei der `python3 salt.py <password>` automatisch den hash-Befehl aufruft
- `salt2.py`: Alternative CLI that imports from `salt.py` and requires explicit subcommands (`generate` and `verify`) - `salt2.py`: Alternative CLI, die aus `salt.py` importiert und explizite Unterbefehle erfordert (`generate` und `verify`)
Both implementations use PBKDF2-HMAC-SHA256 with configurable iteration counts (default: 200,000, overridable via `PBKDF2_ITERATIONS` env var). Beide Implementierungen verwenden PBKDF2-HMAC-SHA256 mit konfigurierbarer Iterationsanzahl (Standard: 200.000, überschreibbar über die Umgebungsvariable `PBKDF2_ITERATIONS`).
## Common Commands ## Häufige Befehle
### Running the CLI ### CLI ausführen
```bash ```bash
# Hash a password (salt.py supports shortcut syntax) # Passwort hashen (salt.py unterstützt Abkürzungssyntax)
python3 salt.py "MyPassword" python3 salt.py "MeinPasswort"
python3 salt.py hash "MyPassword" python3 salt.py hash "MeinPasswort"
# Verify a password # Passwort verifizieren
python3 salt.py verify <password> <salt_b64> <hash_b64> python3 salt.py verify <passwort> <salt_b64> <hash_b64>
# Alternative CLI (requires explicit subcommands) # Alternative CLI (erfordert explizite Unterbefehle)
python3 salt2.py generate "MyPassword" python3 salt2.py generate "MeinPasswort"
python3 salt2.py verify <password> <salt_b64> <hash_b64> python3 salt2.py verify <passwort> <salt_b64> <hash_b64>
``` ```
### Testing ### Testen
```bash ```bash
# Run all tests # Alle Tests ausführen
python3 -m pytest python3 -m pytest
# Run specific tests with verbose output # Spezifische Tests mit ausführlicher Ausgabe ausführen
python3 -m pytest -k verify --maxfail=1 -vv python3 -m pytest -k verify --maxfail=1 -vv
# Run tests for a specific module # Tests für ein bestimmtes Modul ausführen
python3 -m pytest tests/test_hashing.py python3 -m pytest tests/test_hashing.py
``` ```
### Dependencies ### Abhängigkeiten
Dependencies are listed in `requirements.txt`. Install with: Abhängigkeiten sind in `requirements.txt` aufgelistet. Installation mit:
```bash ```bash
pip install -r requirements.txt pip install -r requirements.txt
``` ```
## Code Architecture ## Code-Architektur
### Module Structure ### Modulstruktur
- **salt.py**: Core module containing `hash_password()` and `verify_password()` functions, plus an integrated CLI via `main()` - **salt.py**: Kernmodul mit den Funktionen `hash_password()` und `verify_password()` sowie einer integrierten CLI über `main()`
- **salt2.py**: Wrapper CLI that imports from `salt.py` and provides an alternative command structure - **salt2.py**: Wrapper-CLI, die aus `salt.py` importiert und eine alternative Befehlsstruktur bietet
- **tests/**: Test suite mirroring the module structure - **tests/**: Test-Suite, die die Modulstruktur widerspiegelt
- `test_hashing.py`: Tests for core hashing/verification functions - `test_hashing.py`: Tests für Kern-Hashing-/Verifizierungsfunktionen
- `test_cli.py`: Tests for CLI behavior (specifically `salt.py`'s shortcut syntax) - `test_cli.py`: Tests für CLI-Verhalten (speziell die Abkürzungssyntax von `salt.py`)
### Key Functions ### Hauptfunktionen
**`hash_password(password, *, iterations=None, salt_bytes=16) -> tuple[str, str]`** **`hash_password(password, *, iterations=None, salt_bytes=16) -> tuple[str, str]`**
- Generates a cryptographically secure random salt - Generiert ein kryptographisch sicheres zufälliges Salt
- Derives a hash using PBKDF2-HMAC-SHA256 - Leitet einen Hash mit PBKDF2-HMAC-SHA256 ab
- Returns base64-encoded (salt, hash) tuple - Gibt ein base64-kodiertes (Salt, Hash) Tupel zurück
**`verify_password(password, salt_b64, hash_b64, *, iterations=None) -> bool`** **`verify_password(password, salt_b64, hash_b64, *, iterations=None) -> bool`**
- Validates a password against stored salt/hash - Validiert ein Passwort gegen gespeichertes Salt/Hash
- Uses timing-safe comparison via `hmac.compare_digest()` - Verwendet zeitkonstanten Vergleich über `hmac.compare_digest()`
- Returns `False` for invalid base64 without raising exceptions - Gibt `False` bei ungültigem base64 zurück, ohne Exceptions auszulösen
### CLI Argument Handling ### CLI-Argumentbehandlung
The `salt.py` module includes `_normalize_args()` which allows shortcut syntax: if the first argument is not a subcommand (`hash`/`verify`) and not a flag, it's automatically prefixed with `hash`. This is tested in `tests/test_cli.py:test_main_supports_hash_shortcut()`. Das Modul `salt.py` enthält `_normalize_args()`, welches die Abkürzungssyntax ermöglicht: Wenn das erste Argument kein Unterbefehl (`hash`/`verify`) und kein Flag ist, wird automatisch `hash` vorangestellt. Dies wird in `tests/test_cli.py:test_main_supports_hash_shortcut()` getestet.
## Development Guidelines ## Entwicklungsrichtlinien
### Python Version and Style ### Python-Version und Stil
- Target Python 3.11+ - Ziel-Python-Version: 3.11+
- Use type annotations on public functions - Typannotationen für öffentliche Funktionen verwenden
- 4-space indentation - 4-Leerzeichen-Einrückung
- Follow `lowercase_with_underscores` naming for functions and variables - `lowercase_with_underscores` Namenskonvention für Funktionen und Variablen befolgen
### Security Practices ### Sicherheitspraktiken
- Always use `os.urandom()` for salt generation (never predictable values) - Immer `os.urandom()` für Salt-Generierung verwenden (niemals vorhersagbare Werte)
- Use `hmac.compare_digest()` for hash comparison to prevent timing attacks - `hmac.compare_digest()` für Hash-Vergleich verwenden, um Timing-Angriffe zu verhindern
- Validate base64 input with `validate=True` parameter - Base64-Eingabe mit `validate=True` Parameter validieren
- Handle encoding errors gracefully by returning `False` rather than raising exceptions - Kodierungsfehler elegant behandeln, indem `False` zurückgegeben wird statt Exceptions auszulösen
### Testing Requirements ### Testanforderungen
- Place tests in `tests/test_<module>.py` matching the module name - Tests in `tests/test_<modul>.py` platzieren, passend zum Modulnamen
- Cover happy paths and error handling (invalid base64, wrong passwords) - Happy Paths und Fehlerbehandlung abdecken (ungültiges base64, falsche Passwörter)
- Include round-trip tests: hash → verify with correct/incorrect passwords - Round-Trip-Tests einschließen: hash → verify mit korrekten/inkorrekten Passwörtern
- Maintain >90% coverage for hashing utilities - >90% Coverage für Hashing-Utilities aufrechterhalten
- When adding new hash algorithms, include regression tests with known salt/hash pairs - Bei Hinzufügen neuer Hash-Algorithmen Regressionstests mit bekannten Salt/Hash-Paaren einschließen
### Configuration ### Konfiguration
- Iteration count defaults to 200,000 but respects `PBKDF2_ITERATIONS` environment variable - Iterationsanzahl standardmäßig 200.000, berücksichtigt aber die Umgebungsvariable `PBKDF2_ITERATIONS`
- Salt size defaults to 16 bytes (configurable via `salt_bytes` parameter) - Salt-Größe standardmäßig 16 Bytes (konfigurierbar über `salt_bytes` Parameter)
## Commit Guidelines ## Commit-Richtlinien
Use imperative subject lines with conventional commit prefixes: Imperativ formulierte Betreffzeilen mit konventionellen Commit-Präfixen verwenden:
- `feat:` for new features - `feat:` für neue Features
- `fix:` for bug fixes - `fix:` für Fehlerbehebungen
- `test:` for test additions/changes - `test:` für Test-Hinzufügungen/-Änderungen
- `refactor:` for code restructuring - `refactor:` für Code-Umstrukturierung
Reference issues with `Fixes #ID` when applicable. PRs should only be opened after tests pass. Issues mit `Fixes #ID` referenzieren, wenn zutreffend. PRs sollten erst nach erfolgreichen Tests eröffnet werden.