ezzetabi Posted May 7, 2004 Posted May 7, 2004 Nothing difficult... if ever need a password generator, a way to make temp file with out worry too much about files that already exists or what ever you can use this... As usual, append to the end of file and call it E.G. ;Creates the temp file for text operations $TempFile = @TempDir & "\" & _RandomText(10) & ".tmp" $TempFile = FileOpen($TempFile) Func _RandomText($N) ;$n is the lenght of string. If $N < 1 Then Return -1 Local $COUNTER, $ALPHA, $RESULT For $COUNTER = 1 To $N If Random() < 0.5 Then $ALPHA = Chr(Random(Asc("A"), Asc("Z") + 1)) Else $ALPHA = Chr(Random(Asc("a"), Asc("z") + 1)) EndIf $RESULT = $RESULT & $ALPHA Next Return $RESULT EndFunc ;==>_RandomText
Nutster Posted May 7, 2004 Posted May 7, 2004 Didn't I put something like this in the help file for Random? David NuttallNuttall Computer Consulting An Aquarius born during the Age of Aquarius AutoIt allows me to re-invent the wheel so much faster. I'm off to write a wizard, a wonderful wizard of odd...
emmanuel Posted May 7, 2004 Posted May 7, 2004 well, it does seem to appear that the middle section of that code is in the help file, though a script-diot like me would not easily make the jump to what ezzetabi posted here... "I'm not even supposed to be here today!" -Dante (Hicks)
emmanuel Posted May 7, 2004 Posted May 7, 2004 so, slap this in front of the random text code and you have a random password generator (though who would use these passwords?)$char = InputBox("Random Password","How many characters?", "10") InputBox("Random Password","Here you go:", _RandomText($char)) "I'm not even supposed to be here today!" -Dante (Hicks)
ezzetabi Posted May 10, 2004 Author Posted May 10, 2004 emmanuel said: Though who would use these passwords?I always wondered too... Maybe people that sets email accounts for others?
emmanuel Posted May 10, 2004 Posted May 10, 2004 heh, yeah, I guess I could use them when a user forgets their password, it'd garuntee that they reset it to something else pdq "I'm not even supposed to be here today!" -Dante (Hicks)
ezzetabi Posted May 18, 2004 Author Posted May 18, 2004 Since I actually found a useful use of it (random passwords), see encryption thread. I improved it Now adds also numbers or write spaces. The probability are calculated counting the number of characters. total chars=63, 26 maiusc, 26 min, 10 digits, 1 space 10/63 = 15.87 % and so go on... Func _RandomText($N) ;$n is the lenght of string. If $N < 1 Then Return -1 Local $COUNTER, $ALPHA, $RESULT, $RANDOM For $COUNTER = 1 To $N $RANDOM = Random() Select Case $RANDOM < .1587 $ALPHA = Chr(Random(Asc("0"), Asc("9") + 1)) Case $RANDOM < .5714 $ALPHA = Chr(Random(Asc("A"), Asc("Z") + 1)) Case $RANDOM < .9841 $ALPHA = Chr(Random(Asc("a"), Asc("z") + 1)) Case Else $ALPHA = " " EndSelect $RESULT = $RESULT & $ALPHA Next Return $RESULT EndFunc ;==>_RandomText
piccaso Posted May 18, 2004 Posted May 18, 2004 (edited) I should check the forum more often, i jut wrote a similar function Func Uniqid() Local $i, $rnd, $rval For $i = 1 To 64 $rnd = Round(Random(1, 3), 0) Select Case $rnd == 1;uc (65-90) $rval = $rval & Chr(Round(Random(65, 90), 0)) Case $rnd == 2;lc (97-112) $rval = $rval & Chr(Round(Random(97, 112), 0)) Case $rnd == 3;nr (48-57) $rval = $rval & Chr(Round(Random(48, 57), 0)) EndSelect Next Return $rval EndFunc ;==>Uniqid i think i'm going to benchmark them and see witch one is faster Edit: And The winner is _RandomText witch generates about 33000 random strings more per hour But why this +1 thing? Edited May 18, 2004 by piccaso CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map
ezzetabi Posted May 19, 2004 Author Posted May 19, 2004 (edited) piccaso said: But why this +1 thing?Just because Random($min,$max) do not include max in the results. So I have to keep $max one higher than the max number (that is Z, z or 9 char number)Since you used Round(), you do not need this, all numbers greater than max - 0.5 will be rounded to max.But I think is redundant force the computer round a number every time when the function already take Int(s) number and you can avoid the problem adding 1. Edited May 19, 2004 by ezzetabi
trids Posted May 19, 2004 Posted May 19, 2004 emmanuel said: though who would use these passwords?Actually, random passwords like this are a very good idea .. And not only for clever file-trashing ..There are commercial applications (and even freeware) that allow you to store your logins and passwords in a single database. => This means all you have to remember is a single password - the one for the database.=> Which in turn means you can improve the strength of the passwords you store in it .. even to the point of making them obscure and difficult for anyone to remember: by using a password generator.So you end up with good strong passwords (unique, mixed case, even including numerics and funny chars), without having to remember them. As I write this, I'm considering an AU3 applet to do just this, using the IDEA encryptor that ezzetabi posted to protect the database. Someone else might have the time and interest too
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now