Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[Bug]: Discrepancy of extended Token with legacy library

未关闭
#21 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
python
领域
backend

调研方向

首先运行 issue 中的 Python 示例,并针对扩展 ADD_TIME token 比较 OpenPAYGOTokenEncoder.generate_token 与 legacy generate_extended_token。跟踪扩展模式下 token 类型和计数的处理方式,然后根据 legacy 输出或明确确认的预期行为验证结果。issue 未提及任何 repository 文件或测试。

由索引模型根据 Issue 内容生成。

描述

bug
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

主要语言
Python
星标
15
派生
15
PR 合并指标
30 天内没有已合并 PR

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

EnAccess/OpenPAYGO-python 的其他 Issue

查看 EnAccess/OpenPAYGO-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。