Jump to content

Recommended Posts

Posted

Hello,

i want use password generating function like this:

MsgBox(0,"Generated Password is:", genPassword(8))

Func genPassword($length)
    $array = StringSplit("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789","")

    $newPassword = ""
    For $X = 1 to $length
        $newPassword &= $array[Random (1, $array[0], 1)]
    Next

    return $newPassword

EndFunc

for getting and using generated random password, inside autoit script. But I don“t know how can i write function output to variable for future use.

Can anyone help me with this beginner stupid question ? I can only write result to Message box, just as it is above.

Tank you

Radovan J.

Posted

Not sure if this is what you mean.

Global $sGenPass

$sGenPass = _GeneratePassword(8)
MsgBox(0, "Generated Password is:", $sGenPass)
ConsoleWrite("Generated Password is:" & $sGenPass & @CRLF)


Func _GeneratePassword($iLength)
    Local $aArray = StringSplit("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", "")

    $sPassword = ""
    For $X = 1 To $iLength
        $sPassword &= $aArray[Random(1, $aArray[0], 1)]
    Next

    Return $sPassword
EndFunc   ;==>genPassword

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
  • Recently Browsing   0 members

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