Skip to content

ValueError: non-hexadecimal number found in fromhex() arg at position 0 #75

Description

@ClimenteA
In [5]: encrypted_data = aes.enc(data_string="your-data")
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[5], line 1
----> 1 encrypted_data = aes.enc(data_string="your-data")

File ~/Documents/social-media-posts-scheduler/.venv/lib/python3.12/site-packages/AES_Python/main.py:176, in AES.enc(self, data_string, file_path, running_mode, key, iv)
    174 if data_string:
    175     if running_mode == "ECB":
--> 176         return self.__ecb_enc(data_string=data_string, keys=self.key_expand(key))
    177     elif running_mode == "CBC":
    178         return self.__cbc_enc(data_string=data_string, keys=self.key_expand(key), iv=iv)

File ~/Documents/social-media-posts-scheduler/.venv/lib/python3.12/site-packages/AES_Python/main.py:543, in AES.key_expand(cls, key)
    536 """
    537 Expands the given key to 11, 13 or 15 round key depending on key length.
    538 :param key: Key that is expanded.
    539 :return: Tuple containing round key matrices.
    540 """
    542 # Format key correctly for the key expansion
--> 543 key_array: NDArray[np.uint8] = np.frombuffer(bytes.fromhex(key), dtype=np.uint8)
    545 # Key expansion setup:
    546 # Determines the number of rounds and the number of words using the key length.
    547 if len(key_array) == 16:

ValueError: non-hexadecimal number found in fromhex() arg at position 0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions