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
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:
- `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
- `salt2.py`: Alternative CLI that imports from `salt.py` and requires explicit subcommands (`generate` and `verify`)
Dies ist ein Python PBKDF2 Passwort-Hashing-Tool mit zwei Implementierungen:
- `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, 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
# Hash a password (salt.py supports shortcut syntax)
python3 salt.py "MyPassword"
python3 salt.py hash "MyPassword"
# Passwort hashen (salt.py unterstützt Abkürzungssyntax)
python3 salt.py "MeinPasswort"
python3 salt.py hash "MeinPasswort"
# Verify a password
python3 salt.py verify <password> <salt_b64> <hash_b64>
# Passwort verifizieren
python3 salt.py verify <passwort> <salt_b64> <hash_b64>
# Alternative CLI (requires explicit subcommands)
python3 salt2.py generate "MyPassword"
python3 salt2.py verify <password> <salt_b64> <hash_b64>
# Alternative CLI (erfordert explizite Unterbefehle)
python3 salt2.py generate "MeinPasswort"
python3 salt2.py verify <passwort> <salt_b64> <hash_b64>
```
### Testing
### Testen
```bash
# Run all tests
# Alle Tests ausführen
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
# Run tests for a specific module
# Tests für ein bestimmtes Modul ausführen
python3 -m pytest tests/test_hashing.py
```
### Dependencies
Dependencies are listed in `requirements.txt`. Install with:
### Abhängigkeiten
Abhängigkeiten sind in `requirements.txt` aufgelistet. Installation mit:
```bash
pip install -r requirements.txt
```
## Code Architecture
## Code-Architektur
### Module Structure
- **salt.py**: Core module containing `hash_password()` and `verify_password()` functions, plus an integrated CLI via `main()`
- **salt2.py**: Wrapper CLI that imports from `salt.py` and provides an alternative command structure
- **tests/**: Test suite mirroring the module structure
- `test_hashing.py`: Tests for core hashing/verification functions
- `test_cli.py`: Tests for CLI behavior (specifically `salt.py`'s shortcut syntax)
### Modulstruktur
- **salt.py**: Kernmodul mit den Funktionen `hash_password()` und `verify_password()` sowie einer integrierten CLI über `main()`
- **salt2.py**: Wrapper-CLI, die aus `salt.py` importiert und eine alternative Befehlsstruktur bietet
- **tests/**: Test-Suite, die die Modulstruktur widerspiegelt
- `test_hashing.py`: Tests für Kern-Hashing-/Verifizierungsfunktionen
- `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]`**
- Generates a cryptographically secure random salt
- Derives a hash using PBKDF2-HMAC-SHA256
- Returns base64-encoded (salt, hash) tuple
- Generiert ein kryptographisch sicheres zufälliges Salt
- Leitet einen Hash mit PBKDF2-HMAC-SHA256 ab
- Gibt ein base64-kodiertes (Salt, Hash) Tupel zurück
**`verify_password(password, salt_b64, hash_b64, *, iterations=None) -> bool`**
- Validates a password against stored salt/hash
- Uses timing-safe comparison via `hmac.compare_digest()`
- Returns `False` for invalid base64 without raising exceptions
- Validiert ein Passwort gegen gespeichertes Salt/Hash
- Verwendet zeitkonstanten Vergleich über `hmac.compare_digest()`
- Gibt `False` bei ungültigem base64 zurück, ohne Exceptions auszulösen
### CLI Argument Handling
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()`.
### CLI-Argumentbehandlung
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
- Target Python 3.11+
- Use type annotations on public functions
- 4-space indentation
- Follow `lowercase_with_underscores` naming for functions and variables
### Python-Version und Stil
- Ziel-Python-Version: 3.11+
- Typannotationen für öffentliche Funktionen verwenden
- 4-Leerzeichen-Einrückung
- `lowercase_with_underscores` Namenskonvention für Funktionen und Variablen befolgen
### Security Practices
- Always use `os.urandom()` for salt generation (never predictable values)
- Use `hmac.compare_digest()` for hash comparison to prevent timing attacks
- Validate base64 input with `validate=True` parameter
- Handle encoding errors gracefully by returning `False` rather than raising exceptions
### Sicherheitspraktiken
- Immer `os.urandom()` für Salt-Generierung verwenden (niemals vorhersagbare Werte)
- `hmac.compare_digest()` für Hash-Vergleich verwenden, um Timing-Angriffe zu verhindern
- Base64-Eingabe mit `validate=True` Parameter validieren
- Kodierungsfehler elegant behandeln, indem `False` zurückgegeben wird statt Exceptions auszulösen
### Testing Requirements
- Place tests in `tests/test_<module>.py` matching the module name
- Cover happy paths and error handling (invalid base64, wrong passwords)
- Include round-trip tests: hash → verify with correct/incorrect passwords
- Maintain >90% coverage for hashing utilities
- When adding new hash algorithms, include regression tests with known salt/hash pairs
### Testanforderungen
- Tests in `tests/test_<modul>.py` platzieren, passend zum Modulnamen
- Happy Paths und Fehlerbehandlung abdecken (ungültiges base64, falsche Passwörter)
- Round-Trip-Tests einschließen: hash → verify mit korrekten/inkorrekten Passwörtern
- >90% Coverage für Hashing-Utilities aufrechterhalten
- Bei Hinzufügen neuer Hash-Algorithmen Regressionstests mit bekannten Salt/Hash-Paaren einschließen
### Configuration
- Iteration count defaults to 200,000 but respects `PBKDF2_ITERATIONS` environment variable
- Salt size defaults to 16 bytes (configurable via `salt_bytes` parameter)
### Konfiguration
- Iterationsanzahl standardmäßig 200.000, berücksichtigt aber die Umgebungsvariable `PBKDF2_ITERATIONS`
- Salt-Größe standardmäßig 16 Bytes (konfigurierbar über `salt_bytes` Parameter)
## Commit Guidelines
## Commit-Richtlinien
Use imperative subject lines with conventional commit prefixes:
- `feat:` for new features
- `fix:` for bug fixes
- `test:` for test additions/changes
- `refactor:` for code restructuring
Imperativ formulierte Betreffzeilen mit konventionellen Commit-Präfixen verwenden:
- `feat:` für neue Features
- `fix:` für Fehlerbehebungen
- `test:` für Test-Hinzufügungen/-Änderungen
- `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.