Skip to content

Hariswar8018/simple_totp_auth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔐 simple_totp_auth

simple_totp_auth

A lightweight Flutter package for generating, verifying, and sharing Time-based One-Time Passwords (TOTP) using QR codes — perfect for adding secure 2FA (Two-Factor Authentication) to any app.

✅ Compatible with Google Authenticator, Microsoft Authenticator, Authy, and more!


Demo Screenshots

Demo Screenshot

Demo Screenshot


✨ Features

  • 🔑 Generate secure Base32 TOTP secrets
  • 🕒 Create & verify 6-digit TOTP codes (RFC 6238)
  • 📱 Generate otpauth:// URIs
  • 📷 Display QR codes for Authenticator setup
  • 📋 Copy secrets to clipboard (cross-platform support)
  • 🧩 Flutter Widget for QR with custom size, color, and logo

🚀 Installation

dependencies:
  simple_totp_auth: ^0.0.2

🧪 Usage

🔐 Generate a Secure Secret Key

final secret = TOTP.generateSecret();

🧮 Generate a TOTP Code (Valid for 30 seconds)

final totp = TOTP(secret: secret);
final code = totp.now();
print("Code: $code");

✅ Verify a Code

final totp = TOTP(secret: secret);
final code = totp.now();
print("Code: $code");

📡 Generate QR-Compatible URI

final uri = totp.generateOTPAuthURI(
  issuer: "MyApp",
  account: "user@example.com",
);
print(uri);


📷 Display the QR Code in Your App

TOTPQrWidget(
  secret: secret,
  issuer: 'MyApp',
  accountName: 'user@example.com',
  logoType: LogoType.asset,         // Choose asset or network
  logoPath: 'images/logo.png',      // Path to the asset or URL for network image
  width: 200,
  height: 200,
  color: Colors.white,
  radiusColor: Colors.blue,
  radiusWidth: 2,
  radius: 16,
  padding: 8,
  margin: 8,
)

📋 Copy Secret to Clipboard (with feedback)

final result = await TOTPUtils.copyToClipboard(secret);
print(result); // "Success" or error message

📦 Platform Support

Platform Support
✅ Android Yes
✅ iOS Yes
✅ Web Yes
✅ Windows Yes
✅ macOS Yes
✅ Linux Yes

Works across all 6 major platforms with no native plugins!


☕ Support the Developer

If you found this package helpful, consider buying me a coffee:

Buy Me a Coffee


Thanks for using simple_totp_auth ❤️

About

A Flutter package to generate and verify TOTP codes with QR setup widget. Works on all platforms.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages