Skip to content

Commit

Permalink
Formatting the code
Browse files Browse the repository at this point in the history
  • Loading branch information
Riad-Attou committed Dec 5, 2024
1 parent a61fd20 commit 7d8a492
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/modules/flappybird/endpoints_flappybird.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@


def genKey(score: int) -> int:
""" Generates a key based on the score of the player. """
"""Generates a key based on the score of the player."""
data = f"{score}"

hash_bytes = hashlib.sha256(data.encode()).digest()
key = int.from_bytes(hash_bytes[:4], byteorder="big")

return key


module = Module(
root="flappybird",
tag="Flappy Bird",
Expand Down Expand Up @@ -104,7 +105,8 @@ async def create_flappybird_score(

if genKey(flappybird_score.value) != flappybird_score.key:
raise HTTPException(
status_code=400, detail="Invalid key for the provided score"
status_code=400,
detail="Invalid key for the provided score",
)

db_flappybird_score = models_flappybird.FlappyBirdScore(
Expand Down

0 comments on commit 7d8a492

Please sign in to comment.