This commit is contained in:
2026-01-21 03:07:35 +09:00
commit 5c7516f60f
19 changed files with 15472 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
using System.Security.Cryptography;
namespace SimPas2_Windows.Managers
{
public class GeneratorManager
{
public GeneratorManager()
{
}
public string GeneratePassword(bool isSecure, int length)
{
const string charset_risky = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
const string charset_secure = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!\"#$%&'()=~-^\\|_@`[{]};:+*<>,./?";
string charset = isSecure ? charset_secure : charset_risky;
byte[] random = RandomNumberGenerator.GetBytes(length);
char[] res = new char[length];
for (int i = 0; i < length; i++)
{
res[i] = charset[random[i] % charset.Length];
}
return new string(res);
}
}
}