public class HOTP extends Object
Constructor and Description |
---|
HOTP() |
Modifier and Type | Method and Description |
---|---|
static String |
generateOTP(byte[] secret,
long movingFactor,
int codeDigits,
boolean addChecksum,
int truncationOffset)
This method generates an OTP value for the given set of parameters.
|
public static String generateOTP(byte[] secret, long movingFactor, int codeDigits, boolean addChecksum, int truncationOffset) throws NoSuchAlgorithmException, InvalidKeyException
secret
- the shared secretmovingFactor
- the counter, time, or other value that
changes on a per use basis.codeDigits
- the number of digits in the OTP, not
including the checksum, if any.addChecksum
- a flag that indicates if a checksum digit
should be appended to the OTP.truncationOffset
- the offset into the MAC result to
begin truncation. If this value is out of
the range of 0 ... 15, then dynamic
truncation will be used.
Dynamic truncation is when the last 4
bits of the last byte of the MAC are
used to determine the start offset.codeDigits
digits plus the optional checksum
digit if requested.NoSuchAlgorithmException
- if no provider makes
either HmacSHA1 or HMAC-SHA-1
digest algorithms available.InvalidKeyException
- The secret provided was not
a valid HMAC-SHA-1 key.Copyright © 2017 JBoss by Red Hat. All rights reserved.