mbt masai
 
Welcome !
         

                                
After experiencing a lot of down time, We decided to move this site to CrystalTech.com. CrystalTech.com is powered by only the finest Windows servers providing the best performance, reliability, and value anywhere.

 Random Password Generator

Author Message
itzviper

  • Total Posts : 1
  • Scores: 0
  • Reward points : 0
  • Joined: 12/20/2007
  • Status: offline
Random Password Generator Thursday, December 20, 2007 2:47 PM (permalink)
0
First i'd like to say hello to everyone. Second, i'm new to VBScript, i've been working with VB for awhile. This is my first shot at VBScript so let me know if I did ok.

 <html>
 	<head>
 		<title>Test</title>
 		
 		<script language="VBScript"><!--
 			Dim PASS_CHAR_ALLOWED, PASS_LEN
 			
 			
 			Sub set_allowed_characters()
 				dim strTemp,strExclude,x
 				
 				PASS_CHAR_ALLOWED = ""
 				
 				set frm = document.forms("frmPWGen")
 				
 				if frm.chkUpper.checked = true then
 					PASS_CHAR_ALLOWED = PASS_CHAR_ALLOWED & "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
 				end if
 				
 				if frm.chkLower.checked = true then
 					PASS_CHAR_ALLOWED = PASS_CHAR_ALLOWED & "abcdefghijklmnopqrstuvwxyz"
 				end if
 				
 				if frm.chkNumbers.checked=true then
 					PASS_CHAR_ALLOWED = PASS_CHAR_ALLOWED & "1234567890"
 				end if
 				
 				if frm.chkSymbols.checked = true then
 					PASS_CHAR_ALLOWED = PASS_CHAR_ALLOWED & "!@#$%^&*()-=_+[]{}\|;:',./<>?" & chr(34)
 				end if
 				
 				strExclude = frm.txtExclude.value
 				
 				for x = 1 to len(strExclude)
 					if instr(PASS_CHAR_ALLOWED,mid(strExclude,x,1)) > 0 then
 						PASS_CHAR_ALLOWED = replace(PASS_CHAR_ALLOWED,mid(strExclude,x,1),"")
 					end if
 				next
 				
 			End Sub
 			
 			Sub cmdGenerate_OnClick
 				dim x
 				set frm = Document.Forms("frmPWGen")
 				
 				if not(isnumeric(frm.txtPWLen.value)) then
 					msgbox "Password Length must be numeric!"
 					exit sub
 				elseif not(isnumeric(frm.txtNumOfPW.value)) then
 					msgbox "Number of Passwords must be numeric!"
 					exit sub
 				end if
 					
 				PASS_LEN = cint(frm.txtPWLen.value)
 				call set_allowed_characters
 				
 				frm.txtPasswords.Value = ""
 				for x = 1 to frm.txtNumOfPW.value
 					frm.txtPasswords.value = frm.txtPasswords.Value & GeneratePassword(PASS_CHAR_ALLOWED) & vbCrLf
 				next
 			End Sub
 			
 			Function GeneratePassword(strCharacters)
 				dim strTempCheck, blnPassCheck
 				dim strTempPass, strTempBit
 				dim x
 				set frm = document.forms("frmPWGen")
 				
 				blnPassCheck = False
 				
 				if frm.chkStartLEtter.checked = true then
 					strTempCheck = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
 					if (frm.chkUpper.checked = false) and (frm.chkLower.checked = false) then
 						msgbox "You can't exclude all upper and lower case letters and still start with a letter!"
 						exit function
 					end if
 					
 					for x = 1 to len(strTempCheck)
 						if instr(strCharacters,mid(strTempCheck,x,1)) > 0 then
 							blnPassCheck = True
 						end if
 					next
 					
 					if blnPassCheck = False then
 						msgbox "You can't exclude all letters and still start with a letter!"
 						exit function
 					end if
 					
 					blnPassCheck = False
 					
 					Randomize
 					
 					do
 						strTempBit = mid(strCharacters,Int((len(strCharacters)) * Rnd + 1),1)
 						if instr(strTempCheck,strTempBit) > 0 then
 							blnPassCheck = True
 						end if
 					loop until blnPassCheck = True
 					
 					strTempPass = strTempBit
 				end if
 				
 				do until len(strTempPass) = PASS_LEN
 					Randomize
 					strTempPass = strTempPass & mid(strCharacters,Int((len(strCharacters)) * Rnd + 1),1)
 				loop
 				
 				GeneratePassword = strTempPass
 			End Function
 			-->
 			</script>
 	</head>
 	
 	<body bgcolor="#bbbbbb">
 		<form id="frmPWGen">
 		<table width="280" border="1" bgcolor="#bbbbbb" bordercolor="#000000" cellpadding="2" cellspacing="0">
 			<tr bgcolor="#3A5FCD"><td colspan="2"><center><font color="#FFFFFF">Password Generator</font></center></td></tr>
 			<tr><td>Password Length:</td><td><input type="text" name="txtPWLen" value="8" size="15"></input></td></tr>
 			<tr><td>Number of passwords:</td><td><input type="text" name="txtNumOfPW" value="1" size="15"></input></td></tr>
 			<tr><td colspan="2"><center><label for="UpperCase">UPPER:</label><input type="checkbox" name="chkUpper" id="UpperCase" checked="true"></label></input>
 			<label for="LowerCase">lower:</label><input type="checkbox" name="chkLower" id="LowerCase" checked="true"></input>
 			<label for="Numbers">numbers:</label><input type="checkbox" name="chkNumbers" id="Numbers" checked="true"></input>
 			<label for="Symbols">symbols:</label><input type="checkbox" name="chkSymbols" id="Symbols" checked="true"></input>
 			<label for="StartLetter">start with letter:</label><input type="checkbox" name="chkStartLetter" id="StartLetter" checked="true"></input>
 			</center></td></tr>
 			<tr><td>Exclude:</td><td><input type="text" name="txtExclude" value="" size="15"></input></td></tr>
 			<tr><td colspan="2"><center><input type="button" name="cmdGenerate" value="Generate Password"></input>
 			<input type="reset" name="cmdReset" value="Reset"></input></center></td></tr>
 			<tr><td colspan="2"><center><textarea name="txtPasswords" cols="30" rows="6">Generated passwords</textarea></center></td></tr>
 		</table>
 		</form>
 	</body>
 
<message edited by itzviper on Thursday, December 20, 2007 2:53 PM>
dim localhost as home
#1
    Meg

    • Total Posts : 123
    • Scores: 6
    • Reward points : 0
    • Joined: 7/13/2006
    • Location: Australia
    • Status: offline
    RE: Random Password Generator Wednesday, December 26, 2007 11:31 AM (permalink)
    0
    Welcome itzviper !
     
     
     
    This script works really well, it gives me an idea for a new script I could use for work, or I could tweak this one. Thanks.
    #2
      morpheus83uk

      • Total Posts : 731
      • Scores: 0
      • Reward points : 0
      • Joined: 8/21/2006
      • Status: offline
      RE: Random Password Generator Friday, December 28, 2007 7:21 AM (permalink)
      0
      Hello,
       
      Again welcome and it works great!! :)
       
      I do have one question though how would I get the actual entire Form/Window the same size as the table and without the scroll bars? I have tried putting HTML tags in like width and height in various parts but I dont get anywhere... plus the fact that I have never done HTML does not exactly help lol
       
      Any help wiould be appreciated :)
       
      Many Thanks
       
      James
      #3
        Meg

        • Total Posts : 123
        • Scores: 6
        • Reward points : 0
        • Joined: 7/13/2006
        • Location: Australia
        • Status: offline
        RE: Random Password Generator Friday, December 28, 2007 10:34 AM (permalink)
        0
        Add under the title tag

          <HTA:APPLICATION 
                    SCROLL="no" 
          >


        And add in the main script body this sub

         Sub Window_Onload 
           window.resizeto 318,382 
         End Sub 
         


        Download a HTA from Microsoft called helpomatic that will make your life easier making HTAs and give you heaps if ideas
        http://www.microsoft.com/downloads/details.aspx?FamilyID=231D8143-F21B-4707-B583-AE7B9152E6D9&displaylang=en
        #4
          doboman

          • Total Posts : 1
          • Scores: 0
          • Reward points : 0
          • Joined: 8/22/2010
          • Status: offline
          RE: Random Password Generator Monday, August 23, 2010 1:00 AM (permalink)
          0
          Here code with small changes
           And.... I found an option to add app. icon

           <html>
                   <head>
                           <title>Password Generator</title>
                    <HTA:APPLICATION 
           BORDER="thin"
           BORDERSTYLE="normal"
           CONTEXTMENU="no"
           ICON="#"
           SCROLL="no"
           MAXIMIZEBUTTON="no">     
           <style>
           TABLE {
           font-family:Arial, Helvetica, sans-serif;
           font-size:14px}
           </style>
           <meta HTTP-EQUIV="REFRESH" content="0; url=#body">    
                           <script language="VBScript"><!--
                                   Dim PASS_CHAR_ALLOWED, PASS_LEN
                                   
                                    Sub Window_Onload 
              window.resizeto 292,352
            End Sub 
                                   Sub set_allowed_characters()
                                           dim strTemp,strExclude,x
                                           
                                           PASS_CHAR_ALLOWED = ""
                                           
                                           set frm = document.forms("frmPWGen")
                                           
                                           if frm.chkUpper.checked = true then
                                                   PASS_CHAR_ALLOWED = PASS_CHAR_ALLOWED & "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
                                           end if
                                           
                                           if frm.chkLower.checked = true then
                                                   PASS_CHAR_ALLOWED = PASS_CHAR_ALLOWED & "abcdefghijklmnopqrstuvwxyz"
                                           end if
                                           
                                           if frm.chkNumbers.checked=true then
                                                   PASS_CHAR_ALLOWED = PASS_CHAR_ALLOWED & "1234567890"
                                           end if
                                           
                                           if frm.chkSymbols.checked = true then
                                                   PASS_CHAR_ALLOWED = PASS_CHAR_ALLOWED & "!@#$%^&*()-=_+[]{}\|;:',./<>?" & chr(34)
                                           end if
                                           
                                           strExclude = frm.txtExclude.value
                                           
                                           for x = 1 to len(strExclude)
                                                   if instr(PASS_CHAR_ALLOWED,mid(strExclude,x,1)) > 0 then
                                                           PASS_CHAR_ALLOWED = replace(PASS_CHAR_ALLOWED,mid(strExclude,x,1),"")
                                                   end if
                                           next
                                           
                                   End Sub
                                   
                                   Sub cmdGenerate_OnClick
                                           dim x
                                           set frm = Document.Forms("frmPWGen")
                                           
                                           if not(isnumeric(frm.txtPWLen.value)) then
                                                   msgbox "Password Length must be numeric!"
                                                   exit sub
                                           elseif not(isnumeric(frm.txtNumOfPW.value)) then
                                                   msgbox "Number of Passwords must be numeric!"
                                                   exit sub
                                           end if
                                                   
                                           PASS_LEN = cint(frm.txtPWLen.value)
                                           call set_allowed_characters
                                           
                                           frm.txtPasswords.Value = ""
                                           for x = 1 to frm.txtNumOfPW.value
                                                   frm.txtPasswords.value = frm.txtPasswords.Value & GeneratePassword(PASS_CHAR_ALLOWED) & vbCrLf
                                           next
                                   End Sub
                                   
                                   Function GeneratePassword(strCharacters)
                                           dim strTempCheck, blnPassCheck
                                           dim strTempPass, strTempBit
                                           dim x
                                           set frm = document.forms("frmPWGen")
                                           
                                           blnPassCheck = False
                                           
                                           if frm.chkStartLEtter.checked = true then
                                                   strTempCheck = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
                                                   if (frm.chkUpper.checked = false) and (frm.chkLower.checked = false) then
                                                           msgbox "You can't exclude all upper and lower case letters and still start with a letter!"
                                                           exit function
                                                   end if
                                                   
                                                   for x = 1 to len(strTempCheck)
                                                           if instr(strCharacters,mid(strTempCheck,x,1)) > 0 then
                                                                   blnPassCheck = True
                                                           end if
                                                   next
                                                   
                                                   if blnPassCheck = False then
                                                           msgbox "You can't exclude all letters and still start with a letter!"
                                                           exit function
                                                   end if
                                                   
                                                   blnPassCheck = False
                                                   
                                                   Randomize
                                                   
                                                   do
                                                           strTempBit = mid(strCharacters,Int((len(strCharacters)) * Rnd + 1),1)
                                                           if instr(strTempCheck,strTempBit) > 0 then
                                                                   blnPassCheck = True
                                                           end if
                                                   loop until blnPassCheck = True
                                                   
                                                   strTempPass = strTempBit
                                           end if
                                           
                                           do until len(strTempPass) = PASS_LEN
                                                   Randomize
                                                   strTempPass = strTempPass & mid(strCharacters,Int((len(strCharacters)) * Rnd + 1),1)
                                           loop
                                           
                                           GeneratePassword = strTempPass
                                   End Function
                                   -->
                                   </script>
                   </head>
                           <body bgcolor="#000000" topmargin="1" leftmargin="1">
           <a name="body">
                           <form id="frmPWGen">
                           <table width="280" border="1" bgcolor="#bbbbbb" bordercolor="#000000" cellpadding="2" cellspacing="0">
                                   <tr bgcolor="#346E99"><td colspan="2"><center>
                                     <font color="#FFFFFF" size="+1" face="Verdana, Arial, Helvetica, sans-serif">Password Generator</font>
                                   </center></td>
                                   </tr>
                                   <tr><td>Password Length:</td><td><input type="text" name="txtPWLen" value="8" size="15"></input></td></tr>
                                   <tr><td>Number of passwords:</td><td><input type="text" name="txtNumOfPW" value="1" size="15"></input></td></tr>
                                   <tr><td colspan="2"><center><label for="UpperCase">UPPER:</label><input type="checkbox" name="chkUpper" id="UpperCase" checked="true"></label></input>
                                   <label for="LowerCase">lower:</label><input type="checkbox" name="chkLower" id="LowerCase" checked="true"></input>
                                   <label for="Numbers">numbers:</label><input type="checkbox" name="chkNumbers" id="Numbers" checked="true"></input>
                                   <label for="Symbols">symbols:</label><input type="checkbox" name="chkSymbols" id="Symbols" checked="true"></input>
                                   <label for="StartLetter">start with letter:</label><input type="checkbox" name="chkStartLetter" id="StartLetter" checked="true"></input>
                                   </center></td></tr>
                                   <tr><td>Exclude:</td><td><input type="text" name="txtExclude" value="" size="15"></input></td></tr>
                                   <tr><td colspan="2"><center><input type="button" name="cmdGenerate" value="Generate Password"></input>
                                   <input type="reset" name="cmdReset" value="Reset"></input></center></td></tr>
                                   <tr><td colspan="2"><center><textarea name="txtPasswords" cols="30" rows="6">Generated passwords</textarea></center></td></tr>
                           </table>
                           </form></a>
                   </body>
            </html>

          #5

            Online Bookmarks Sharing: Share/Bookmark

            Jump to:

            Current active users

            There are 0 members and 1 guests.

            Icon Legend and Permission

            • New Messages
            • No New Messages
            • Hot Topic w/ New Messages
            • Hot Topic w/o New Messages
            • Locked w/ New Messages
            • Locked w/o New Messages
            • Read Message
            • Post New Thread
            • Reply to message
            • Post New Poll
            • Submit Vote
            • Post reward post
            • Delete my own posts
            • Delete my own threads
            • Rate post

            2000-2012 ASPPlayground.NET Forum Version 3.8
            mbt shoes www.wileywilson.com