Skip to content

Commit

Permalink
Add function to generate unique validation code for gift cards.
Browse files Browse the repository at this point in the history
  • Loading branch information
Arman-prevas committed Dec 5, 2023
1 parent 99bcd68 commit 94063a4
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions api/src/shop/gift_card_util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from secrets import token_hex


def generate_gift_card_code(length=16):
"""
Generate a unique validation code for gift cards.
Parameters:
- length: The length of the validation code (default is 16).
Returns:
A unique validation code.
"""
return token_hex(length)[:length]

0 comments on commit 94063a4

Please sign in to comment.