Witam ostatnio napisałem programik który generuje hasła i nie mam pojęcia czemu nie działa, nie ma żadnego błędu. Bardzo proszę o pomoc.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp7
{
public class Program
{
static void Main() { }
public static string GetUniqueKey(int maxSize)
{
char[] chars = new
char[62];
chars =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890".ToCharArray();
byte[] data = new byte[1];
RNGCryptoServiceProvider crypto = new RNGCryptoServiceProvider();
crypto.GetBytes(data);
data = new byte[maxSize];
crypto.GetBytes(data);
StringBuilder result = new StringBuilder(maxSize);
foreach (byte b in data)
{
result.Append(chars[b % (chars.Length)]);
}
return result.ToString();
}
}
}