Orta seviye
19 Ağustos 2026Hatayı bul: Data Science & ML
Tek bir kod parçası. Hatayı bul ya da hata olmadığını kanıtla.
python
1import hashlib
2from sqlalchemy.orm import Session
3from models import User
4
5def register_user(db: Session, email: str, password: str) -> User:
6 hashed = hashlib.md5(password.encode()).hexdigest()
7 user = User(email=email, password_hash=hashed)
8 db.add(user)
9 db.commit()
10 db.refresh(user)
11 return user
12
13def verify_password(db: Session, email: str, password: str) -> bool:
14 user = db.query(User).filter_by(email=email).first()
15 if not user:
16 return False
17 return user.password_hash == hashlib.md5(password.encode()).hexdigest()Soruna yol açan satırlara tıkla.
Kararın
Günde bir deneme. Cevap hemen ardından görünür.
Serini koru
Serini korumak ve ilerlemeni takip etmek için hesap oluştur.