Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Discrepancy of extended Token with legacy library #21

Open
3 tasks done
dmohns opened this issue Nov 5, 2024 · 0 comments
Open
3 tasks done

[Bug]: Discrepancy of extended Token with legacy library #21

dmohns opened this issue Nov 5, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@dmohns
Copy link
Member

dmohns commented Nov 5, 2024

Preflight Checklist

Expected Behavior

Legacy and new library should generate the same extended tokens.

Actual Behavior

When generating extended tokens there is a difference for ADD_TIME tokens.

New lib:

# OpenPAYGO-python
from openpaygo import OpenPAYGOTokenEncoder, TokenType


encoder = OpenPAYGOTokenEncoder()


new_count, final_token = encoder.generate_token(
    secret_key="bc41ec9530f6dac86b1a29ab82edc5fb",
    count=2,
    value=1,
    token_type=TokenType.ADD_TIME,
    starting_code=516959010,
    restricted_digit_set=False,
    extended_token=True,
)

print(f"{new_count=}")
print(f"{final_token=}")

yields

new_count=4
final_token='584694959011'

Legacy:

# OpenPAYGO Token
import codecs
from importlib import import_module


openpaygo_token = import_module("openpaygo-token")
encoder = openpaygo_token.OPAYGOEncoder()
shared = openpaygo_token.OPAYGOShared


new_count, final_token = encoder.generate_extended_token(
    key=codecs.decode("bc41ec9530f6dac86b1a29ab82edc5fb", "hex"),
    count=2,
    value=1,
    # mode=shared.TOKEN_TYPE_ADD_TIME,
    starting_code=516959010,
    restricted_digit_set=False,
)

print(f"{new_count=}")
print(f"{final_token=}")
new_count=3
final_token='660362959011'

Steps to reproduce

Run the code from above.

This might be related to the legacy being hardcoded to SET_TIME for extended mode. Is the expected behaviour?

What operating system(s) are you using?

macOS

Additional Information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant