Generate a password - Leo-Corporation/LeoCorpLibrary Wiki

Table of content


Introduction

To generate a password using LeoCorpLibrary, you must include this line of code on top of your code file:

C#

using LeoCorpLibrary;

VB

Imports LeoCorpLibrary

Functions

a. Generate

To generate a password, you need to call the Generate() method, in:

LeoCorpLibrary.Password.Generate()

It returns a string value. This method has two variations.

Generate(length, chars, separator)

This method is available in version 1.4 and higher.

Framework LeoCorpLibrary LeoCorpLibrary.Core
.NET 5
.NET Core 3.1
.NET Framework 4.7.2
.NET Framework 4.5

This method has a few parameters:

Type Paramètre Description Exemple
int length Lenght of the password 10
string chars Characters that are used to generate the password "a,b,c,d"
string separator Separator ","

Here's an example of usage:

C#

Console.WriteLine(Password.Generate(10, "a,b,c,d", ","));

VB

Console.WriteLine(Password.Generate(10, "a,b,c,d", ","))

Go to top

Generate(length, passwordPresets)

This method is available in version 2.4 and higher.

Framework LeoCorpLibrary LeoCorpLibrary.Core
.NET 5
.NET Core 3.1
.NET Framework 4.7.2
.NET Framework 4.5

This method has a few parameters:

Type Paramètre Description Exemple
int length Lenght of the password 10
PasswordPresets passwordPresets The preset used for the password generation PasswordPresets.Simple

Here's an example of usage:

C#

Console.WriteLine(Password.Generate(10, PasswordPresets.Simple));

VB

Console.WriteLine(Password.Generate(10, PasswordPresets.Simple))

Go to top

b. GenerateAsync

To generate a password, you need to call the GenerateAsync() method, in:

LeoCorpLibrary.Password.GenerateAsync()

It returns a Task<string> value. This method has two variations.

GenerateAsync(length, chars, separator)

This method is available in version 2.4 and higher.

Framework LeoCorpLibrary LeoCorpLibrary.Core
.NET 5
.NET Core 3.1
.NET Framework 4.7.2
.NET Framework 4.5

This method has a few parameters:

Type Parameter Description Example
int length Lenght of the password 10
string chars Characters that are used to generate the password "a,b,c,d"
string separator Separator ","

Here's an example of usage:

C#

Console.WriteLine(await Password.GenerateAsync(10, "a,b,c,d", ","));

VB

Console.WriteLine(Await Password.GenerateAsync(10, "a,b,c,d", ","))

Go to top

GenerateAsync(length, passwordPresets)

This method is available in version 2.4 and higher.

Framework LeoCorpLibrary LeoCorpLibrary.Core
.NET 5
.NET Core 3.1
.NET Framework 4.7.2
.NET Framework 4.5

This method has a few parameters:

Type Parameter Description Example
int length Lenght of the password 10
PasswordPresets passwordPresets The preset used for the password generation PasswordPresets.Simple

Here's an example of usage:

C#

Console.WriteLine(await Password.GenerateAsync(10, PasswordPresets.Simple));

VB

Console.WriteLine(Await Password.GenerateAsync(10, PasswordPresets.Simple))

Go to top

c. GenerateAmount

To generate multiple passwords you need to call this method, in.

LeoCorpLibrary.Password.GenerateAmount()

It returns a List<string> value. This method has two variations.

GenerateAmount(amount, length, chars, separator)

This method is available in version 3.7 and higher.

Framework LeoCorpLibrary LeoCorpLibrary.Core
.NET 5
.NET Core 3.1
.NET Framework 4.7.2
.NET Framework 4.5

This method has a few parameters:

Type Paramètre Description Exemple
int amount Number of passwords to generate 20
int length Lenght of the password 10
string chars Characters that are used to generate the password "a,b,c,d"
string separator Separator ","

Here's an example of usage:

C#

List<string> passwords = Password.GenerateAmount(20, 10, "a,b,c,d", ",");

for (int i = 0; i < passwords.Count; i++) // For each password
{
    Console.WriteLine(passwords[i]); // Print password in console
}

VB

Dim passwords As List(Of String) = Password.GenerateAmount(20, 10, "a,b,c,d", ",")

For i As Integer = 0 To passwords.Count - 1 ' For each password
    Console.WriteLine(passwords(i)) ' Print password in console
Next

Go to top

GenerateAmount(amount, length, passwordPresets)

This method is available in version 3.7 and higher.

Framework LeoCorpLibrary LeoCorpLibrary.Core
.NET 5
.NET Core 3.1
.NET Framework 4.7.2
.NET Framework 4.5

This method has a few parameters:

Type Paramètre Description Exemple
int amount Number of passwords to generate 20
int length Lenght of the password 10
PasswordPresets passwordPresets The preset used for the password generation PasswordPresets.Simple

Here's an example of usage:

C#

List<string> passwords = Password.GenerateAmount(20, 10, PasswordPresets.Complex);

for (int i = 0; i < passwords.Count; i++) // For each password
{
    Console.WriteLine(passwords[i]); // Print password in console
}

VB

Dim passwords As List(Of String) = Password.GenerateAmount(20, 10, PasswordPresets.Complex)

For i As Integer = 0 To passwords.Count - 1 ' For each password
    Console.WriteLine(passwords(i)) ' Print password in console
Next

Go to top

d. GenerateAmountAsync

To generate multiple passwords asynchronously you need to call this method, in.

LeoCorpLibrary.Password.GenerateAmountAsync()

It returns a Task<List<string>> value. This method has two variations.

GenerateAmountAsync(amount, length, chars, separator)

This method is available in version 3.7 and higher.

Framework LeoCorpLibrary LeoCorpLibrary.Core
.NET 5
.NET Core 3.1
.NET Framework 4.7.2
.NET Framework 4.5

This method has a few parameters:

Type Parameter Description Example
int amount Number of passwords to generate 20
int length Lenght of the password 10
string chars Characters that are used to generate the password "a,b,c,d"
string separator Separator ","

Here's an example of usage:

C#

List<string> passwords = await Password.GenerateAmountAsync(20, 10, "a,b,c,d", ",");

for (int i = 0; i < passwords.Count; i++) // For each password
{
    Console.WriteLine(passwords[i]); // Print password in console
}

VB

Dim passwords As List(Of String) = Await Password.GenerateAmountAsync(20, 10, "a,b,c,d", ",")

For i As Integer = 0 To passwords.Count - 1 ' For each password
     Console.WriteLine(passwords(i)) ' Print password in console
Next

Go to top

GenerateAmountAsync(amount, length, passwordPresets)

This method is available in version 3.7 and higher.

Framework LeoCorpLibrary LeoCorpLibrary.Core
.NET 5
.NET Core 3.1
.NET Framework 4.7.2
.NET Framework 4.5

This method has a few parameters:

Type Parameter Description Example
int amount Number of passwords to generate 20
int length Lenght of the password 10
PasswordPresets passwordPresets The preset used for the password generation PasswordPresets.Simple

Here's an example of usage:

C#

List<string> passwords = await Password.GenerateAmountAsync(20, 10, PasswordPresets.Complex);

for (int i = 0; i < passwords.Count; i++) // For each password
{
    Console.WriteLine(passwords[i]); // Print password in console
}

VB

Dim passwords As List(Of String) = Await Password.GenerateAmountAsync(20, 10, PasswordPresets.Complex)

For i As Integer = 0 To passwords.Count - 1 ' For each password
    Console.WriteLine(passwords(i)) ' Print password in console
Next

Go to top

e. GetPasswordStrength

This method is available in version 3.8 and higher.

Framework LeoCorpLibrary LeoCorpLibrary.Core
.NET 5
.NET Core 3.1
.NET Framework 4.7.2
.NET Framework 4.5

The GetPasswordStrength() method allows you to evaluate a password's strength using Passliss' standards. It returns a PasswordStrength enum.

It's in:

LeoCorpLibrary.Password.GetPasswordStrength() {...}

It has one argument:

Type Argument Description Example
string password The password to test "Ftel_UGbn542"

Here's an example of usage:

C#

string[] passwords =
{
	"Ifhi2ztbg1",
	"pars132",
	"Lo8_n0D",
	"uifVyuiVVH_çVIvc",
	"gygYUI4"
};
		
List<PasswordStrength> forces = new List<PasswordStrength>();
		
for (int i = 0; i < passwords.Length; i++)
{
	forces.Add(Password.GetPasswordStrength(passwords[i]));
}

/* 
forces' content:
Medium
Low
Good
VeryGood
Medium
*/

VB

Dim passwords As String() = {"Ifhi2ztbg1", "pars132", "Lo8_n0D", "uifVyuiVVH_çVIvc", "gygYUI4"}

Dim forces As List(Of PasswordStrength) = New List(Of PasswordStrength)()

For i As Integer = 0 To passwords.Length - 1
    forces.Add(Password.GetPasswordStrength(passwords(i)))
Next
' forces' content:
' Medium
' Low
' Good
' VeryGood
' Medium

Go to top

Enumerations

a. PasswordStrength

This enumeration is available in version 3.8 and higher.

The PasswordStrength enumeration can be equal to:

Go to top