Skip to content

otplib API Documentation / otplib / generateSync

Function: generateSync()

generateSync(options): string

Defined in: otplib/src/functional.ts:254

Generate an OTP code synchronously

This is the synchronous version of generate. It requires a crypto plugin that supports synchronous HMAC operations.

Parameters

options

OTPFunctionalOptions

OTP generation options

Returns

string

OTP code

Throws

If the crypto plugin doesn't support sync operations

Example

ts
import { generateSync } from 'otplib';

const token = generateSync({
  secret: 'JBSWY3DPEHPK3PXP',
});

Released under the MIT License.