Net Encryption Library
One Time Password
Basic Tasks > One Time Password

One Time Password Overview

The .NET Encryption Library can be used to generate a one time password of six digits based on a key.  The one time password is good for the specified number of seconds.  The example below creates a one time password that is valid for one second.

 

C# Copy Code
Encryption encryption = new Encryption(); //Trial Mode
//Encryption encryption = new Encryption("place user name here", "place license key here"); //License Mode
 
string oneTimePassword = encryption.CreateTimedOneTimePassword("SecretPassword", 1);
Console.WriteLine(oneTimePassword);
Assert.IsTrue(encryption.VerifyTimeOneTimePassword("SecretPassword", 1, oneTimePassword));
 
System.Threading.Thread.Sleep(1000);
 
string anotherOneTimePassword = encryption.CreateTimedOneTimePassword("SecretPassword", 1);
Console.WriteLine(anotherOneTimePassword);
Assert.AreNotEqual(oneTimePassword, anotherOneTimePassword);
VB.NET Copy Code
Dim encryption As New Encryption() 'Trial Mode
'Encryption encryption = new Encryption("place user name here", "place license key here"); //License Mode
 
Dim oneTimePassword As String = encryption.CreateTimedOneTimePassword("SecretPassword", 1)
Console.WriteLine(oneTimePassword)
Assert.IsTrue(encryption.VerifyTimeOneTimePassword("SecretPassword", 1, oneTimePassword))
 
System.Threading.Thread.Sleep(1000)
 
Dim anotherOneTimePassword As String = encryption.CreateTimedOneTimePassword("SecretPassword", 1)
Console.WriteLine(anotherOneTimePassword)
Assert.AreNotEqual(oneTimePassword, anotherOneTimePassword)