473,386 Members | 1,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

passwodrd genaration

Hi,
I would like genarate of 6 alpha nuemaric characters
password automatically in ASP.NET.plz
how to make it.

Waiting for the reply.

krishna
Nov 21 '05 #1
3 1063
I don't know about 'ASP' but in vb you could use this function:

....
Dim strPassword As String
Dim intCount As Integer
Try
For intCount = 0 To 5
strPassword &= GetRandomPasswordChar()
Next
....

Private Function GetRandomPasswordChar() As Char

Dim objRandom As Random
Dim objTimer As DateTime
Dim intChar As Integer
Dim intTicks As Integer
Dim dblStart As Double

Try
REM Create timer.
objTimer = New DateTime()
REM Get 'random' value for Random class constructor.
intTicks = Convert.ToInt32(DateTime.Now.Millisecond)
REM Wait for a few milliseconds to create different values.
dblStart = objTimer.Now.TimeOfDay.TotalMilliseconds()
While objTimer.Now.TimeOfDay.TotalMilliseconds() - dblStart < 13
Application.DoEvents()
End While
REM Create Random object.
objRandom = New Random(intTicks)
REM Get random value between 48 ('0') and 122 ('z').
intChar = objRandom.Next(48, 122)
REM Make sure character value is valid.
While (intChar > 57 And intChar < 65) Or (intChar > 90 And
intChar < 97)
intChar = objRandom.Next(48, 122)
End While
REM Return char.
Return Convert.ToChar(intChar)
Catch X As Exception
Return Convert.ToChar("-"c) ' Failed.
End Try

End Function

"krishna" <ve*************@gamil.com> schreef in bericht
news:1f****************************@phx.gbl...
Hi,
I would like genarate of 6 alpha nuemaric characters
password automatically in ASP.NET.plz
how to make it.

Waiting for the reply.

krishna

Nov 21 '05 #2
This would do the trick a little better. It still produces about 15
duplicant passwords out of 500 passwords 6 characters long.
Private Function GetRandomPasswordChar() As Char

Dim objRandom As Random
Dim objTimer As DateTime
Dim intChar, intWait As Integer
Dim lngTicks As Double
Dim dblStart As Double

Try
REM Create timer.
objTimer = New DateTime()
REM Get 'random' value for Random class constructor.
lngTicks = objTimer.Now.TimeOfDay.Ticks
While lngTicks >= 2147483647 ' Max value of integer
lngTicks /= 2
End While
REM Create Random object.
objRandom = New Random(Convert.ToInt32(lngTicks))
REM Get random value between 10 and 50.
intWait = objRandom.Next(10, 50)
REM Wait for a few milliseconds to create different values.
dblStart = objTimer.Now.TimeOfDay.TotalMilliseconds()
While objTimer.Now.TimeOfDay.TotalMilliseconds() - dblStart <
intWait
Application.DoEvents()
End While
REM Get random value between 48 ('0') and 122 ('z').
intChar = objRandom.Next(48, 122)
REM Make sure character value is valid.
While (intChar > 57 And intChar < 65) Or (intChar > 90 And
intChar < 97)
intChar = objRandom.Next(48, 122)
End While
REM Return char.
Return Convert.ToChar(intChar)
Catch X As Exception
Return Convert.ToChar("-"c) ' Failed.
End Try

End Function
Nov 21 '05 #3
"Qwert" <no**@nosp.com> schrieb:
objRandom = New Random(Convert.ToInt32(lngTicks))


The paramterless constructor of 'Random' will use a clock-based seed value
automatically.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: krishna | last post by:
Hi, I would like genarate of 6 alpha nuemaric characters password automatically in ASP.NET.plz how to make it. Waiting for the reply. krishna
14
by: Piotrek | last post by:
Hi all. I have a web app, in which I use frames. My main frameset consists of three inner frames. When some button is pressed in frame A, then content of frame B is reloaded. I am using such...
2
by: sekharnns | last post by:
Hai I am sekhar working as a SE in Bangalore. Any one can please tell how to gearate PDF file from ASP.net application with web page data. Thanks & Regards Sekhar
1
by: TheSebaster | last post by:
I wrote the following lines of code under Microsoft Visual Studio 2005: I compile my WinCE c++ application importing MyInterop.tlb generated file. The MyInterop.tlh generated file do not contain my...
3
by: halwiindims | last post by:
I want to repair a corrupt Microsoft Win XP Professional version 2002, I recieved an error for a missing system file usbehci.sys. Setup is now just pinting to the same XP CD even when restarting the...
2
by: parasuram | last post by:
Hi friends ............. this is a question regarding the data structures trees Pleas post it if possible with in 2 days I will thankful if some body could help doing this. Operating...
3
vikysaran
by: vikysaran | last post by:
hi, please check http://www.golsinc.com/app7/ i need to make it in such way that when user moves his pointer inside the image, it generates coordinated inside the textbox. after one click it...
0
vikysaran
by: vikysaran | last post by:
Hello, please check 1. http://www.golsinc.com/app7/demo1.aspx (On IE) and 2. http://www.golsinc.com/app7/ (On Firefox) when you click on image on 2nd url i gave, it creats a Circle,...
4
by: nazimsal | last post by:
Imports System.Data.SqlClient Namespace Accounts Public Class NewAccount Dim cmd As New SqlCommand Dim c As New DatabaseConnection.DataBaseConnaction.ConnectionClass ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.