An open API service indexing awesome lists of open source software.

https://github.com/ediwang/edi.passwordgenerator

Generate secure password
https://github.com/ediwang/edi.passwordgenerator

Last synced: about 1 year ago
JSON representation

Generate secure password

Awesome Lists containing this project

README

          

# Edi.PasswordGenerator

[![.NET Build and Pack](https://github.com/EdiWang/Edi.PasswordGenerator/actions/workflows/dotnet.yml/badge.svg)](https://github.com/EdiWang/Edi.PasswordGenerator/actions/workflows/dotnet.yml)

Generate secure password, but I am not sure, so use it on your own risk.

## Install from NuGet

```powershell
dotnet add package Edi.PasswordGenerator
```

```powershell
NuGet\Install-Package Edi.PasswordGenerator
```

```xml

```

## Usage

### .NET

```csharp
var gen = new DefaultPasswordGenerator();

// Using classic ASP.NET MVC membership method
var p1 = gen.GeneratePassword(new(10, 3));
// example: WSI:R=6s(C

// Quickly get a password
var p2 = gen.GeneratePassword();
// example: ou45V8La%X

```

### ASP.NET Core

Register `IPasswordGenerator` in DI container.

```csharp
services.AddTransient();
```

```csharp
[HttpGet("password/generate")]
[ProducesResponseType(StatusCodes.Status200OK)]
public IActionResult GeneratePassword([FromServices] IPasswordGenerator passwordGenerator)
{
var password = passwordGenerator.GeneratePassword(new(10, 3));
return Ok(new
{
ServerTimeUtc = DateTime.UtcNow,
Password = password
});
}
```