Ask a Question related to ASP.NET Security, Design and Development.
-
Zhwgnon Flrq #1
Generating random passwords
Hello all:
I am trying to build a standar Web registration screen and was wondering of
what algo to use to generate a random password for users.
Any kind of help would be greatly appreciated.
Thanks.
Zhwgnon Flrq Guest
-
Using Math.random to go to random frames
Hello everyone. My cerebral density is preventing me from seeing the solution to this problem. I have the following code which causes the user to... -
Generating random numbers?
Can someone remind me of the name for the class/method for generating random numbers? I did a quick grep through the library and a google, but all... -
Random image in a random place.
Anyone know javascript? I have a grid(4 x 4) of 16 spacer images and a few text links on the side. Each text link represents a different folder of... -
Why are passwords in /etc?
This may be a silly question: Why is /etc/shadow in /etc? Generally, applications and static data go in /usr. You could mount /usr read-only... -
generating random numbers
How do I generate a random number between 1 and 10? I need to capture information of potential clients and randomly assign them to salespersons.... -
amit agarwal #2
Generating random passwords
and was wondering of>-----Original Message-----
>Hello all:
>
>I am trying to build a standar Web registration screenThis article shows how to generate a random alpha-numeric>what algo to use to generate a random password for users.
>
>Any kind of help would be greatly appreciated.
>
>Thanks.
>
>
>.
password for an online user-registration. Calling the
function GeneratePassword() will return a alpha-numeric
string of 10 digits (in this example) which can be sent as
a system generated password to the user and the relevant
record in the database. To generate a particular digit
password, change the 10 in GeneratePassword() function to
your choice.
private string GetPassword(int nLength)
{
int i;
double nRnd;
Random oRandom;
string c="";
int a, b, d;
bool bMadeConsonant = false;
const string strAllConsonants="bcdfghjklmnpqrstvwxyz";
const string strVocal = "aeiou";
const string intnum="0123456789";
string sPassword = "";
for(i=0;i < nLength;i++)
{
oRandom = new Random();
nRnd = oRandom.NextDouble();
if(sPassword != "" && !bMadeConsonant && (nRnd < 0.30))
{
a = Convert.ToInt16(intnum.Length *
oRandom.NextDouble()) + 1;
c = intnum.Substring(a,1);
c = c + c;
i = i + 1;
bMadeConsonant = true;
}
else
{
if(!bMadeConsonant && (nRnd< 0.60))
{
try
{
b = Convert.ToInt16(strAllConsonants.Length *
oRandom.NextDouble()) + 1;
c = strAllConsonants.Substring(a, 1);
bMadeConsonant = true;
}
catch(ArgumentOutOfRangeException)
{}
}
else
{
try
{
d = Convert.ToInt16(strVocal.Length *
oRandom.NextDouble()) + 1;
c = strVocal.Substring(d, 1);
bMadeConsonant = false;
}
catch(ArgumentOutOfRangeException)
{}
}
}
sPassword += c;
}
if(sPassword.Length > nLength)
sPassword = sPassword.Substring(0,nLength);
return sPassword;
}
public string GeneratePassword()
{
string sPasswd=GetPassword(10);
while(sPasswd=="")
sPasswd=GetPassword(10);
return sPasswd;
}
>amit agarwal Guest
-
Zhwgnon Flrq #3
Re: Generating random passwords
Amit:
The code you sent did not compile. Anyways, I wrote a similar function (a
lot simplified though) to generate a random password of length 8.
// This function generates a random alphanumeric password of length 8.
private string GenerateRandomPassword ()
{
const string alphabets = "abcdefghijklmnopqrstuvwxyz";
const string digits ="0123456789";
StringBuilder password = new StringBuilder (8);
Random rng = new Random ();
int n = 0;
for (int i = 0; i < 8; ++i)
{
if (i % 2 == 0)
{
n = rng.Next (26);
password.Append (alphabets [n]);
}
else
{
n = rng.Next (10);
password.Append (digits [n]);
}
}
return password.ToString ();
}
Thanks.
"amit agarwal" <amit_agarwal@idealake.com> wrote in message
news:068101c3ce9e$b9aaa9b0$a401280a@phx.gbl...>> and was wondering of> >-----Original Message-----
> >Hello all:
> >
> >I am trying to build a standar Web registration screen>> >what algo to use to generate a random password for users.
> >
> >Any kind of help would be greatly appreciated.
> >
> >Thanks.
> >
> >
> >.
> This article shows how to generate a random alpha-numeric
> password for an online user-registration. Calling the
> function GeneratePassword() will return a alpha-numeric
> string of 10 digits (in this example) which can be sent as
> a system generated password to the user and the relevant
> record in the database. To generate a particular digit
> password, change the 10 in GeneratePassword() function to
> your choice.
> private string GetPassword(int nLength)
> {
> int i;
> double nRnd;
> Random oRandom;
> string c="";
> int a, b, d;
> bool bMadeConsonant = false;
> const string strAllConsonants="bcdfghjklmnpqrstvwxyz";
> const string strVocal = "aeiou";
> const string intnum="0123456789";
> string sPassword = "";
> for(i=0;i < nLength;i++)
> {
> oRandom = new Random();
> nRnd = oRandom.NextDouble();
> if(sPassword != "" && !bMadeConsonant && (nRnd < 0.30))
> {
> a = Convert.ToInt16(intnum.Length *
> oRandom.NextDouble()) + 1;
> c = intnum.Substring(a,1);
> c = c + c;
> i = i + 1;
> bMadeConsonant = true;
> }
> else
> {
> if(!bMadeConsonant && (nRnd< 0.60))
> {
> try
> {
> b = Convert.ToInt16(strAllConsonants.Length *
> oRandom.NextDouble()) + 1;
> c = strAllConsonants.Substring(a, 1);
> bMadeConsonant = true;
> }
> catch(ArgumentOutOfRangeException)
> {}
> }
> else
> {
> try
> {
> d = Convert.ToInt16(strVocal.Length *
> oRandom.NextDouble()) + 1;
> c = strVocal.Substring(d, 1);
> bMadeConsonant = false;
> }
> catch(ArgumentOutOfRangeException)
> {}
> }
> }
> sPassword += c;
> }
> if(sPassword.Length > nLength)
> sPassword = sPassword.Substring(0,nLength);
> return sPassword;
> }
>
> public string GeneratePassword()
> {
> string sPasswd=GetPassword(10);
> while(sPasswd=="")
> sPasswd=GetPassword(10);
> return sPasswd;
> }
>
>
>> >
Zhwgnon Flrq Guest



Reply With Quote

