Skip to content

Commit

Permalink
bytes.fromhex instead of quote
Browse files Browse the repository at this point in the history
  • Loading branch information
BuildTools committed Nov 12, 2023
1 parent bd7b14e commit 655c114
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/heckbot/cogs/picker.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ def get_pick_link(user_name: str) -> str:
token, iv = encrypt(user_name, expiry)
return (
PICK_SERVER_URL +
f'/form?token={quote(b64encode(token))}'
f'&iv={quote(b64encode(iv))}'
f'/form?token={quote(token.hex())}'
f'&iv={quote(iv.hex())}'
)


Expand Down
4 changes: 4 additions & 0 deletions src/heckbot/utils/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@

def encrypt(username: str, expiry: str) -> tuple[bytes, bytes]:
message = f'{username}:{expiry}'.encode()

# Ensure the message length is a multiple of the block size (16 bytes for AES)
while len(message) % 16 != 0:
message += b'\x00'
iv = os.urandom(16)
cipher = Cipher(
algorithms.AES(
Expand Down

0 comments on commit 655c114

Please sign in to comment.