hotp.go
func (otp *HOTP) IntegrityCheck() (string, uint64) {
	h := hmac.New(sha1.New, otp.Key)
	counter := make([]byte, 8)
	h.Write(counter)
	hash := h.Sum(nil)
	result := truncate(hash)

	mod := new(big.Int).Exp(big.NewInt(10), big.NewInt(int64(otp.Digits)), nil)
	mod = mod.Mod(big.NewInt(result), mod)
	fmtStr := fmt.Sprintf("%%0%dd", otp.Digits)
	return fmt.Sprintf(fmtStr, mod.Uint64()), otp.Counter()
}
func (otp *HOTP) IntegrityCheck() (string, uint64) {
	h := hmac.New(sha1.New, otp.Key)
	counter := make([]byte, 8)
	h.Write(counter)
	hash := h.Sum(nil)
	result := truncate(hash)

	mod := new(big.Int).Exp(big.NewInt(10), big.NewInt(int64(otp.Digits)), nil)
	mod = mod.Mod(big.NewInt(result), mod)
	fmtStr := fmt.Sprintf("%%0%dd", otp.Digits)
	return fmt.Sprintf(fmtStr, mod.Uint64()), otp.Counter()
}
func ( otp * HOTP ) IntegrityCheck ( ) ( string , uint64 ) { h := hmac . New ( sha1 . New , otp . Key ) counter := make ( [ ] byte , 8 ) h . Write ( counter ) hash := h . Sum ( nil ) result := truncate ( hash ) mod := new ( big . Int ) . Exp ( big . NewInt ( 10 ) , big . NewInt ( int64 ( otp . Digits ) ) , nil ) mod = mod . Mod ( big . NewInt ( result ) , mod ) fmtStr := fmt . Sprintf ( " " , otp . Digits ) return fmt . Sprintf ( fmtStr , mod . Uint64 ( ) ) , otp . Counter ( ) }
// IntegrityCheck returns two values, the base OTP and the current
// counter. This is used, for example, with the Google Authenticator
// app's "Check key value" function and can be used to verify that
// the application and the provider are in sync.
IntegrityCheck returns two values the base OTP and the current counter . This is used for example with the Google Authenticator app s Check key value function and can be used to verify that the application and the provider are in sync .