A full-featured Time-Based One-Time Password (TOTP) library for React Native, providing functions for generating and validating OTP codes.
- New Architecture Support
- Written in C++
- Generate Secret Key
- Generate OTP
- Validate OTP
- JSI Implementation
Using npm:
npm install react-native-totp-utils
Using yarn:
yarn add react-native-totp-utils
import {
generateOTP,
generateSecretKey,
validateOTP,
formatSecretKey,
formatOTP,
} from 'react-native-totp-utils';
// ...
const secretKey = generateSecretKey(); // ABCDABCDABCD
const otp = generateOTP(secretKey); // 123456
const isValid = validateOTP(secretKey, otp); // true
const formattedSecretKey = formatSecretKey(secretKey); // ABCD-ABCD-ABCD-ABCD
const formattedOTP = formatOTP(otp); // 123 456
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT
Made with create-react-native-library