Skip to content

Commit

Permalink
fix: return bytes from _data_to_message
Browse files Browse the repository at this point in the history
  • Loading branch information
robberwick committed Nov 17, 2024
1 parent 9b622b5 commit 11d115e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/blinkstick/blinkstick.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ def get_info_block2(self) -> str:
result += chr(i)
return result

def _data_to_message(self, data) -> bytes:
def _data_to_message(self, data: str) -> bytes:
"""
Helper method to convert a string to byte array of 32 bytes.
Expand All @@ -464,14 +464,14 @@ def _data_to_message(self, data) -> bytes:
@rtype: byte[32]
@return: It fills the rest of bytes with zeros.
"""
bytes = [1]
byte_array = bytearray([1])
for c in data:
bytes.append(ord(c))
byte_array.append(ord(c))

for i in range(32 - len(data)):
bytes.append(0)
byte_array.append(0)

return bytes
return bytes(byte_array)

def set_info_block1(self, data: str) -> None:
"""
Expand Down

0 comments on commit 11d115e

Please sign in to comment.