> For the complete documentation index, see [llms.txt](https://doc.duaer.com/zh/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.duaer.com/zh/build/totp.md).

# 在 Duaer 里用 TOTP 生成验证码

在 Duaer 里，TOTP 默认 Operation 是 Generate Secret。Options 里 Algorithm 默认 SHA1，Digits 默认 6，Period 默认 30。需要 totpApi 凭据（存 label 与 secret）。
## 生成当前验证码

1. 先建好 totpApi 凭据（填 Label 与 Secret）。
2. 搜索 TOTP，接到上一个节点后面，选上凭据。
3. Operation 保持 Generate Secret。
4. 需要时在 Options 里改 Algorithm、Digits、Period。
5. 点执行此步骤，输出里会有当前码。

凭据里的 Secret 是共享密钥，不要写进数字组织明文。

相关密码学节点见 [在 Duaer 里用 JWT 签发令牌](/zh/build/jwt.md)、[在 Duaer 里用 Crypto 做哈希](/zh/build/crypto.md)。
## Questions

### Duaer 的 TOTP Generate Secret 是新建密钥吗？

面板 Operation 名是 Generate Secret，实际是按凭据里的 secret 生成当前时段验证码，不是每次新建密钥。

## 相关

- [在 Duaer 里用 JWT 签发令牌](https://doc.duaer.com/zh/build/jwt.md)
- [在 Duaer 里用 Crypto 做哈希](https://doc.duaer.com/zh/build/crypto.md)
- [在 Duaer 里用 HTTP Request 调接口](https://doc.duaer.com/zh/build/http-request.md)

