smartotps
v1.1.0
Published
Generate OTP tokens from key
Downloads
41
Maintainers
Readme
smartotp.sdk.react-native
import {SmartOtp} from "./index";
const secret = 'JBSWY3DPEHPK3PXP';
async function testTOTP() {
try {
const { otp, expires } = await SmartOtp.generate(secret, {
digits: 6,
algorithm: 'SHA-1',
encoding: 'hex',
period: 30,
});
console.log(`Generated OTP: ${otp}`);
console.log(`Expires at: ${new Date(expires).toLocaleTimeString()}`);
} catch (error) {
console.error('Error generating OTP:', error);
}
}
// Run the test
testTOTP();