/react-native-totp-utils

A full-featured Time-Based One-Time Password (TOTP) library for React Native witten in C++

Primary LanguageC++MIT LicenseMIT

react-native-totp-utils

A full-featured Time-Based One-Time Password (TOTP) library for React Native, providing functions for generating and validating OTP codes.

Features

  • New Architecture Support
  • Written in C++
  • Generate Secret Key
  • Generate OTP
  • Validate OTP
  • JSI Implementation

Installation

Using npm:

npm install react-native-totp-utils

Using yarn:

yarn add react-native-totp-utils

Usage

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

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library