CoolFace
Apppublic

vikrant892/password-strength-api

sourceHugging Faceupdated 1mo agoView on Hugging Face
0likes
models.py41 linesDownload Raw Back to app
1from pydantic import BaseModel, Field
2from typing import Optional
3
4
5class AnalyzeRequest(BaseModel):
6    password: str = Field(..., min_length=1, max_length=256)
7    check_breach: bool = Field(default=False, description="check HIBP for breaches")
8
9
10class AnalyzeResponse(BaseModel):
11    score: int = Field(..., ge=0, le=100)
12    label: str
13    entropy_bits: float
14    crack_time_display: str
15    suggestions: list[str]
16    breached: Optional[bool] = None
17    breach_count: Optional[int] = None
18
19
20class GenerateRequest(BaseModel):
21    length: int = Field(default=16, ge=8, le=128)
22    uppercase: bool = True
23    lowercase: bool = True
24    digits: bool = True
25    symbols: bool = True
26    exclude_ambiguous: bool = Field(
27        default=False,
28        description="exclude chars like 0/O, 1/l/I that look similar"
29    )
30
31
32class GenerateResponse(BaseModel):
33    password: str
34    score: int
35    entropy_bits: float
36
37
38class HealthResponse(BaseModel):
39    status: str = "ok"
40    version: str = "0.1.0"
41