-
Notifications
You must be signed in to change notification settings - Fork 3
Generate a password
- Introduction
- Functions
- Enumerations
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
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.
This method is available in version 1.4 and higher.
Compatibility
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", ","))
This method is available in version 2.4 and higher.
Compatibility
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))
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.
This method is available in version 2.4 and higher.
Compatibility
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", ","))
This method is available in version 2.4 and higher.
Compatibility
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))
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.
This method is available in version 3.7 and higher.
Compatibility
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
This method is available in version 3.7 and higher.
Compatibility
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
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.
This method is available in version 3.7 and higher.
Compatibility
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
This method is available in version 3.7 and higher.
Compatibility
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
This method is available in version 3.8 and higher.
Compatibility
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
This enumeration is available in version 3.8 and higher.
The PasswordStrength
enumeration can be equal to:
- Low
- Medium
- Good
- VeryGood
© 2021 Léo Corporation and contributors