{"id":26833314,"url":"https://github.com/mr-won/otp_program","last_synced_at":"2025-03-30T15:28:40.297Z","repository":{"id":284065845,"uuid":"953706960","full_name":"mr-won/otp_program","owner":"mr-won","description":"otp_program ","archived":false,"fork":false,"pushed_at":"2025-03-24T00:32:39.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-24T01:23:13.933Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mr-won.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-24T00:05:17.000Z","updated_at":"2025-03-24T00:32:43.000Z","dependencies_parsed_at":"2025-03-24T01:23:28.456Z","dependency_job_id":"26939017-4948-4677-8f12-1e4462756171","html_url":"https://github.com/mr-won/otp_program","commit_stats":null,"previous_names":["mr-won/otp_program"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mr-won%2Fotp_program","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mr-won%2Fotp_program/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mr-won%2Fotp_program/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mr-won%2Fotp_program/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mr-won","download_url":"https://codeload.github.com/mr-won/otp_program/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246337742,"owners_count":20761262,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-30T15:28:39.840Z","updated_at":"2025-03-30T15:28:40.282Z","avatar_url":"https://github.com/mr-won.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"```python\nimport time\nimport hmac\nimport base64\nimport struct\nimport hashlib\n\n// 카운터 기반\ndef get_hotp_token(secret, intervals_no, digits=6):\n    key = base64.b32decode(secret, True)\n    msg = struct.pack(\"\u003eQ\", intervals_no)\n    h = hmac.new(key, msg, hashlib.sha1).digest()\n    o = h[19] \u0026 15\n    token = (struct.unpack(\"\u003eI\", h[o:o+4])[0] \u0026 0x7fffffff) % (10**digits)\n    return str(token).zfill(digits)\n\n// 시간 기반\ndef get_totp_token(secret, time_step=30, digits=6):\n    return get_hotp_token(secret, int(time.time() / time_step), digits)\n\n# 테스트용 시크릿 키 (실제 운영에서는 보안이 강화된 키 사용)\nsecret_key = \"JBSWY3DPEHPK3PXP\"\n\n# 현재 OTP 생성\notp = get_totp_token(secret_key)\nprint(\"현재 OTP:\", otp)\n```\nHOTP HMAC을 기반으로한 한번제공되는 패스워드 생성\n시크릿키 \u003c- base32로 인코딩\nintervals_no \u003c- otp 생성 지점\ndigits : otp 자릿수를 설정합니다. 기본값은 6자리로 줬습니다.  \n\nbase32 인코딩 된 시크릿 키를 디코딩하고\nintervals_no 값을 8바이트 64비트 빅 엔디안 형식으로 변환한 후 \nhmac-sha1 해시 계산하고, 다이제스트의 마지막 바이트에서 4비트를 가져옵니다.\n\notp를 계산하고 지정된 자릿수로 변환해준다.\n\n다음으로 TOTP 시간을 기반으로한 한번제공되는 패스워드 생성함수 설명\ntime_step -\u003e otp 변경 주기를 30초로 했습니다.\ndigits : otp 자릿수를 설정\n\n현재 otp를 totp 함수에 시크릿키를 넣어서 현재 시간을 기반으로한 hotp를 호출, \n\n\ntotp -\u003e hotp -\u003e opt 6자리 출력\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmr-won%2Fotp_program","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmr-won%2Fotp_program","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmr-won%2Fotp_program/lists"}