← 返回题库
中级

模拟设备注册与API Key颁发

未完成
中级参考 代码结构已给出,请填写 ____ 处
def solve():
    from pyodide.http import open_url
    from io import StringIO
    import pandas as pd, hashlib, secrets
    keys_csv = open_url(____).read()
    keys = pd.read_csv(StringIO(____))
    def register_device(____):
        raw_key = f"____"
        prefix = raw_key[:____]
        key_hash = hashlib.sha256(raw_key.encode()).hexdigest()
        return {'____':device_id,'____':prefix,'____':key_hash,'____':____,'____':raw_key}
    new_devices = ['____','____']
    for did in new_devices:
        reg = register_device(____)
        print(____)
    print(____)
    print(____)

示例

输入
solve()
期望输出
注册 DEV011: prefix=sk_dev011_378c28, hash=a76adcb33fa21f00...
注册 DEV012: prefix=sk_dev012_6e4c1b, hash=e801dd276d5301f9...
已有设备Key数: 10
活跃Key: 9
Python 代码 🔒 登录后使用
🔒

登录后即可练习

注册免费账号,在浏览器中直接运行 Python 代码