Open
Description
As a user, it currently doesn't become very clear how the extended token features are used.
The code adds to the confusion with a lot of hardcoded values
@classmethod
def convert_hash_to_token(cls, this_hash):
token = cls._convert_to_40_bits(
this_hash
) # We convert the 64bits value to an INT no greater than 12 digits
return token
@classmethod
def _convert_to_40_bits(cls, source):
mask = ((1 << (64 - 24 + 1)) - 1) << 24
temp = (source & mask) >> 24
if temp > 999999999999:
temp = temp - 99511627777
return temp
The odd - 99511627777
seems very arbitrary.
Please, update the documentation to
- Better reflect the relation between input token length (in chars) and the internal data storage type
- Document whether this relation is completely dynamic (i.e. users can chose to have tokens of length 11) or if they have to pick from 10, 12 and 15
Please also update the code base in all languages to work with all supported modes. From a brief look
- Python can currently handle 10 and 12 token length: https://github.com/EnAccess/OpenPAYGO-python/blob/main/openpaygo/token_shared_extended.py#L30-L35
- C can currently handle 10 and 12 token length: https://github.com/EnAccess/OpenPAYGO-HW/blob/main/src/extended/opaygo_core_extended.c#L15-L29
- Either remove unneeded dynamic and hardcode 10 or 12 token length or add full support for arbitrary token length