myOtpGenerator 4.0.0

dotnet add package myOtpGenerator --version 4.0.0
                    
NuGet\Install-Package myOtpGenerator -Version 4.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="myOtpGenerator" Version="4.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="myOtpGenerator" Version="4.0.0" />
                    
Directory.Packages.props
<PackageReference Include="myOtpGenerator" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add myOtpGenerator --version 4.0.0
                    
#r "nuget: myOtpGenerator, 4.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package myOtpGenerator@4.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=myOtpGenerator&version=4.0.0
                    
Install as a Cake Addin
#tool nuget:?package=myOtpGenerator&version=4.0.0
                    
Install as a Cake Tool

myOtpGenerator

Version 4.0 – Advanced and secure OTP (One-Time Password) generation library for .NET

Overview

myOtpGenerator is a lightweight, multi-framework OTP library for .NET developers. It provides a secure and flexible way to generate OTPs for authentication, verification, or 2FA.

Features include:

Numeric OTPs (default)

OTPs with prefix/suffix

Unique OTPs with timestamp

OTP hashing (SHA256)

Multiple OTP generation

Advanced features in v4.0:

OTP expiration (set expiry in minutes)

Alphanumeric OTPs (stronger, harder to guess)

Retry-limit validation

No-repeat OTPs

Secure storage & verification

Supported .NET versions: net45, net461, net47, net48, netstandard2.0, net9.0

Comparison: v3.1 vs v4.0 Feature v3.1 v4.0 Numeric OTP ✅ ✅ OTP with prefix/suffix ✅ ✅ Unique OTP with timestamp ✅ ✅ OTP hashing (SHA256) ✅ ✅ Multiple OTP generation ✅ ✅ OTP expiration ❌ ✅ Alphanumeric OTP ❌ ✅ Retry-limit validation ❌ ✅ No-repeat OTPs ❌ ✅ Multi-framework support ✅ ✅ Secure random generation ✅ ✅ Installation Install-Package myOtpGenerator -Version 4.0.0

Usage Examples

  1. Generate Numeric OTP (default) using OtpGenerator;

var otpGen = new Otp(); string otp = otpGen.GenerateOtp(6); Console.WriteLine($"OTP: {otp}");

  1. Generate Expiring OTP var expOtp = otpGen.GenerateOtpWithExpiry(6, 5); // Expires in 5 minutes Console.WriteLine($"OTP: {expOtp.Code}, Expires at: {expOtp.Expiry}"); Console.WriteLine($"Is expired? {expOtp.IsExpired()}");

  2. Generate Alphanumeric OTP string alphaOtp = otpGen.GenerateAlphanumericOtp(8); Console.WriteLine($"Alphanumeric OTP: {alphaOtp}");

  3. Retry-limited OTP Validation var validator = otpGen.GetValidator("123456", 3);

Console.WriteLine(validator.Validate("111111")); // false Console.WriteLine(validator.Validate("123456")); // true Console.WriteLine($"Attempts left: {validator.AttemptsLeft}"); // Shows remaining attempts

  1. OTP with Prefix or Suffix string prefixedOtp = otpGen.GenerateOtpWithPrefix("AUTH", 6); string suffixedOtp = otpGen.GenerateOtpWithSuffix("LOGIN", 6);

Console.WriteLine(prefixedOtp); // e.g., AUTH-123456 Console.WriteLine(suffixedOtp); // e.g., 123456-LOGIN

  1. Unique OTP without Repeats string uniqueOtp = otpGen.GenerateUniqueOtpNoRepeat(6); Console.WriteLine(uniqueOtp);

  2. OTP Hashing for Secure Storage string otpHash = otpGen.HashOtp("123456"); Console.WriteLine($"Hashed OTP: {otpHash}");

  3. Generate Multiple OTPs at Once string[] multipleOtps = otpGen.GenerateMultipleOtps(5, 6); foreach (var o in multipleOtps) { Console.WriteLine(o); }

Advanced Use Case: Full OTP Flow var otpGen = new Otp();

// 1️⃣ Generate OTP var expOtp = otpGen.GenerateOtpWithExpiry(6, 3); // 3 min expiry Console.WriteLine($"OTP: {expOtp.Code}");

// 2️⃣ Store hashed OTP for secure verification string otpHash = otpGen.HashOtp(expOtp.Code);

// 3️⃣ User enters OTP string userInput = "123456";

// 4️⃣ Validate OTP and expiry bool isValid = !expOtp.IsExpired() && otpGen.ValidateOtp(expOtp.Code, userInput); Console.WriteLine($"Is OTP valid? {isValid}");

50+ NuGet Tags for Discoverability

OTP, generator, security, authentication, 2FA, MFA, one-time-password, random, hashing, cryptography, verification, mobile, web, API, token, secure, numeric, alphanumeric, expiry, expiring, retry-limit, validation, hash, SHA256, timestamp, unique, prefix, suffix, multi-framework, netstandard, netcore, netframework, desktop, server, backend, CSharp, dotnet, dotnetlibrary, library, package, NuGet, open-source, MIT, authenticator, login, user-verification, developer-tool, security-tool, otp-generator, advanced-OTP

License

MIT License © Shaikh Khujrat

If you want, I can also create a “v4.0 Release Note + Migration Guide” for users who are upgrading from 3.1 to 4.0, so they can see exactly what changes affect them and how to integrate new features safely.

Do you want me to do that next?

You said: yes ChatGPT said:

Perfect! Here’s a complete “v4.0 Release Notes + Migration Guide” for your NuGet package myOtpGenerator, designed to help users upgrading from v3.1. You can include this in your GitHub repository or NuGet page.

myOtpGenerator v4.0 – Release Notes & Migration Guide

Release Date: 2025-10-24 Version: 4.0.0

1️⃣ Highlights of v4.0

v4.0 introduces advanced OTP features while keeping all v3.1 functionality intact.

Key improvements:

Feature v3.1 v4.0 Numeric OTP ✅ ✅ OTP with prefix/suffix ✅ ✅ Unique OTP with timestamp ✅ ✅ OTP hashing (SHA256) ✅ ✅ Multiple OTP generation ✅ ✅ OTP expiration ❌ ✅ Alphanumeric OTP ❌ ✅ Retry-limit validation ❌ ✅ No-repeat OTPs ❌ ✅ Multi-framework support ✅ ✅ Secure random generation ✅ ✅ 2️⃣ Breaking Changes

✅ None – all existing APIs from v3.1 remain unchanged.

Backward compatible: Users upgrading from 3.1 do not need to change existing numeric OTP calls, prefix/suffix usage, or hashing functionality.

3️⃣ New Features in v4.0

  1. OTP Expiration

Generate OTPs that automatically expire after a set time.

var expOtp = otpGen.GenerateOtpWithExpiry(6, 5); // 5 min expiry Console.WriteLine(expOtp.Code); Console.WriteLine(expOtp.IsExpired());

  1. Alphanumeric OTP

Generate stronger OTPs combining letters and numbers.

string alphaOtp = otpGen.GenerateAlphanumericOtp(8); Console.WriteLine(alphaOtp);

  1. Retry-Limited OTP Validation

Prevent unlimited OTP attempts.

var validator = otpGen.GetValidator("123456", 3); Console.WriteLine(validator.Validate("111111")); // false Console.WriteLine(validator.AttemptsLeft); // 2

  1. No-Repeat OTPs

Avoid generating the same OTP twice in a short period.

string uniqueOtp = otpGen.GenerateUniqueOtpNoRepeat(6); Console.WriteLine(uniqueOtp);

  1. Secure OTP Hashing

Hash OTPs for secure storage or verification.

string otpHash = otpGen.HashOtp("123456"); Console.WriteLine(otpHash);

4️⃣ Migration Guide (3.1 → 4.0) Scenario Old (v3.1) New (v4.0) Notes Numeric OTP GenerateOtp(6) Same No changes needed Prefix/Suffix GenerateOtpWithPrefix("AUTH") Same Compatible Unique OTP GenerateUniqueOtp(6) Same Compatible OTP hashing HashOtp(otp) Same Compatible Multiple OTPs GenerateMultipleOtps(5,6) Same Compatible OTP expiration ❌ GenerateOtpWithExpiry(6, 5) New optional feature Alphanumeric OTP ❌ GenerateAlphanumericOtp(8) New optional feature Retry limit ❌ GetValidator(otp, 3) New optional feature No-repeat OTP ❌ GenerateUniqueOtpNoRepeat(6) New optional feature

Upgrade Instructions:

Update NuGet Package:

Update-Package myOtpGenerator -Version 4.0.0

Existing code continues to work.

Optional: integrate new features for enhanced security.

5️⃣ Recommendations

Use OTP expiration for time-sensitive authentication flows.

Use alphanumeric OTPs for stronger security.

Use retry-limited validation to prevent brute-force attacks.

Use no-repeat OTPs in systems generating multiple OTPs rapidly.

Always hash OTPs before storing in a database.

6️⃣ Full Example – v4.0 Flow var otpGen = new Otp();

// Generate an expiring alphanumeric OTP var expOtp = otpGen.GenerateOtpWithExpiry(8, 5); Console.WriteLine($"OTP: {expOtp.Code}, Expires: {expOtp.Expiry}");

// Store hashed OTP string otpHash = otpGen.HashOtp(expOtp.Code);

// Validate OTP with retry limit var validator = otpGen.GetValidator(expOtp.Code, 3); bool isValid = validator.Validate("user_input"); Console.WriteLine($"Is valid? {isValid}, Attempts left: {validator.AttemptsLeft}");

7️⃣ License

MIT License © Shaikh Khujrat

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 is compatible.  net462 was computed.  net463 was computed.  net47 is compatible.  net471 was computed.  net472 was computed.  net48 is compatible.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.5

    • No dependencies.
  • .NETFramework 4.6.1

    • No dependencies.
  • .NETFramework 4.7

    • No dependencies.
  • .NETFramework 4.8

    • No dependencies.
  • .NETStandard 2.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.0 161 10/24/2025
3.1.0 180 6/27/2025
3.0.0 143 6/27/2025
2.1.0 171 11/13/2024
2.0.0 142 11/13/2024

v4.0: Added OTP expiration, alphanumeric OTP, retry limit, no-repeat OTP, and advanced security features while keeping all v3.1 features intact.