Modifier and Type | Field and Description |
---|---|
static Duration |
DEFAULT_TIME_STEP
默认步进 (30秒).
|
DEFAULT_PASSWORD_LENGTH, HOTP_HMAC_ALGORITHM
Constructor and Description |
---|
TOTP(byte[] key)
构造,使用默认HMAC算法(HmacSHA1)
|
TOTP(Duration timeStep,
byte[] key)
构造,使用默认HMAC算法(HmacSHA1)
|
TOTP(Duration timeStep,
int passwordLength,
byte[] key)
构造,使用默认HMAC算法(HmacSHA1)
|
TOTP(Duration timeStep,
int passwordLength,
HmacAlgorithm algorithm,
byte[] key)
构造
|
Modifier and Type | Method and Description |
---|---|
int |
generate(Instant timestamp)
使用给定的时间戳生成一次性密码.
|
Duration |
getTimeStep()
获取步进
|
generate, getAlgorithm, getPasswordLength
public static final Duration DEFAULT_TIME_STEP
public TOTP(byte[] key)
key
- 共享密码,RFC 4226要求最少128位public TOTP(Duration timeStep, byte[] key)
timeStep
- 日期步进,用于生成移动因子(moving factor)key
- 共享密码,RFC 4226要求最少128位public TOTP(Duration timeStep, int passwordLength, byte[] key)
timeStep
- 日期步进,用于生成移动因子(moving factor)passwordLength
- 密码长度,可以是6,7,8key
- 共享密码,RFC 4226要求最少128位public TOTP(Duration timeStep, int passwordLength, HmacAlgorithm algorithm, byte[] key)
timeStep
- 日期步进,用于生成移动因子(moving factor)passwordLength
- 密码长度,可以是6,7,8algorithm
- HMAC算法枚举key
- 共享密码,RFC 4226要求最少128位Copyright © 2021. All rights reserved.