marhanen
06-21-2006, 07:17 PM
OK i have this code but i'm not sure if its asp.net all he said was that it runs in .net and if it is how would i be able to run it.
using System;
using System.Collections;
using System.Security.Cryptography;
using System.Text;
public class PasswordGenerator
{
private const int DefaultMaximum = 25;
private const int DefaultMinimum = 25;
private string exclusionSet;
private int maxSize;
private int minSize;
private char[] pwdCharArray = "BCDFGHJKLMNPQRSTVWXYZ0123456789".ToCharArray();
public PasswordGenerator()
{
Minimum = DefaultMinimum;
Maximum = DefaultMaximum;
Exclusions = null;
}
private char[] GetAvailableChars()
{
ArrayList result = new ArrayList(pwdCharArray);
char[] exclusions = String.Empty.ToCharArray();
if (exclusionSet != null)
{
exclusions = exclusionSet.ToCharArray();
}
foreach (char exclusion in exclusions)
{
result.Remove(exclusion);
}
return (char[]) result.ToArray(typeof(char));
}
public string Generate()
{
int size = maxSize;
byte[] data = new byte[1];
char[] availableChars = GetAvailableChars();
RNGCryptoServiceProvider crypto = new RNGCryptoServiceProvider();
crypto.GetNonZeroBytes(data);
size = (data[0] % (maxSize - minSize)) + minSize;
data = new byte[size];
crypto.GetNonZeroBytes(data);
StringBuilder result = new StringBuilder(size);
foreach(byte datum in data)
{
result.Append(availableChars[datum % (availableChars.Length - 1)]);
}
return result.ToString();
}
public string Exclusions
{
get { return exclusionSet; }
set { exclusionSet = value; }
}
public int Maximum
{
get { return this.maxSize; }
set
{
this.maxSize = value;
if (this.minSize >= this.maxSize)
{
this.maxSize = PasswordGenerator.DefaultMaximum;
}
}
}
public int Minimum
{
get { return this.minSize; }
set
{
this.minSize = value;
if (PasswordGenerator.DefaultMinimum > this.minSize)
{
this.minSize = PasswordGenerator.DefaultMinimum;
}
}
}
}
its kind of old so i cant ask him myself
thanks
Marhanen
using System;
using System.Collections;
using System.Security.Cryptography;
using System.Text;
public class PasswordGenerator
{
private const int DefaultMaximum = 25;
private const int DefaultMinimum = 25;
private string exclusionSet;
private int maxSize;
private int minSize;
private char[] pwdCharArray = "BCDFGHJKLMNPQRSTVWXYZ0123456789".ToCharArray();
public PasswordGenerator()
{
Minimum = DefaultMinimum;
Maximum = DefaultMaximum;
Exclusions = null;
}
private char[] GetAvailableChars()
{
ArrayList result = new ArrayList(pwdCharArray);
char[] exclusions = String.Empty.ToCharArray();
if (exclusionSet != null)
{
exclusions = exclusionSet.ToCharArray();
}
foreach (char exclusion in exclusions)
{
result.Remove(exclusion);
}
return (char[]) result.ToArray(typeof(char));
}
public string Generate()
{
int size = maxSize;
byte[] data = new byte[1];
char[] availableChars = GetAvailableChars();
RNGCryptoServiceProvider crypto = new RNGCryptoServiceProvider();
crypto.GetNonZeroBytes(data);
size = (data[0] % (maxSize - minSize)) + minSize;
data = new byte[size];
crypto.GetNonZeroBytes(data);
StringBuilder result = new StringBuilder(size);
foreach(byte datum in data)
{
result.Append(availableChars[datum % (availableChars.Length - 1)]);
}
return result.ToString();
}
public string Exclusions
{
get { return exclusionSet; }
set { exclusionSet = value; }
}
public int Maximum
{
get { return this.maxSize; }
set
{
this.maxSize = value;
if (this.minSize >= this.maxSize)
{
this.maxSize = PasswordGenerator.DefaultMaximum;
}
}
}
public int Minimum
{
get { return this.minSize; }
set
{
this.minSize = value;
if (PasswordGenerator.DefaultMinimum > this.minSize)
{
this.minSize = PasswordGenerator.DefaultMinimum;
}
}
}
}
its kind of old so i cant ask him myself
thanks
Marhanen