Jump to content

How To Simplify My Code?


Recommended Posts

well, i'm new here and i'm brazilian, so i dont speak english as well

but ok, i made a simple program that create passwords, but the script is too big and i wanna know how can i make it smaller.

here is the code:

Global $array[12]
$array[11] = "l"
$array[10] = "k"
$array[9] = "j"
$array[8] = "i"
$array[7] = "h"
$array[6] = "g"
$array[5] = "f"
$array[4] = "e"
$array[3] = "d"
$array[2] = "c"
$array[1] = "b"
$array[0] = "a"

    $b = Random(0, 11, 1)
    $c = Random(0, 11, 1)
    $d = Random(0, 11, 1)
    $e = Random(0, 11, 1)
    $f = Random(0, 11, 1)
    $g = Random(0, 11, 1)
    $h = Random(0, 11, 1)
    $i = Random(0, 11, 1)
    $j = Random(0, 11, 1)
    $k = Random(0, 11, 1)
    $l = Random(0, 11, 1)
    $m = Random(0, 11, 1)
    MsgBox(0, "Gerated Password", $array[$b] & $array[$c] & $array[$d] & $array[$e] & $array[$f] _
    & $array[$g] & $array[$h] & $array[$i] & $array[$j] & $array[$k] & $array[$l] & $array[$m])

you all can see that its a big file, and i'm only using 12 letters

thanks for the help

Edited by gring0

Never judge my awesome brazilian-english language :D:D<-- lol ;P

Link to comment
Share on other sites

  • Developers

This is a routne that will return a password of the requested length and uses randomly A-Z, a-z 0-9

MsgBox(0, "password", GenPassWord(5))
; Generate New Password
Func GenPassWord($length)
    Local $psw = ""
    For $x = 1 To $length
        $r = Random(1, 3, 1)
        Select
            Case $r = 1
                $psw = $psw & Chr(48 + Random(0, 9, 1))
            Case $r = 2
                $psw = $psw & Chr(65 + Random(0, 25, 1))
            Case $r = 3
                $psw = $psw & Chr(97 + Random(0, 25, 1))
        EndSelect
    Next
    Return $psw
EndFunc  ;==>GenPassWord

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...