Sign in to follow this  
Followers 0
gring0

How To Simplify My Code?

3 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



$Password = ""
For $i = 1 To 12
    $Password &= Chr (Random (97, 108, 1))
Next
MsgBox (0, "pass", $Password)

&= uses beta, so get it if you don't have it, or use $Password = $Password & Chr (Random (97, 108, 1)) instead.

Share this post


Link to post
Share on other sites

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

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
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
Sign in to follow this  
Followers 0