Random can choose random numbers.
But what about random letters or any other symbols?
Does it mean, that I need to create an array, and put there all the "a, A, b, B, c, C, ..." (and other symbols) and then make a loop with a Random, as much times, as I want my potential new password's length gonna be?
Do you know the most effective way to build a code for that?
Thanks
How to create a password generator?
Re: How to create a password generator?
Code: Select all
MsgBox, 64, Your new password, % newPass(8)
newPass(length) {
Loop, %length% {
Random, rand, 33, 126
pass .= Chr(rand)
}
Return pass
}
Re: How to create a password generator?
Thanks for that.
And how about passwords made from just lowercase, UPPERCASE and numbers?
48-57 (the digits 0-9)
65-90 (uppercase A-Z)
97-122 (lowercase a-z)
How to make Random choose symbols from those three ranges?
--------
And can you say what 64 means right after MsgBox ?
Re: How to create a password generator?
That's wonderful. I provided the information for you because I was answering your question.
Re: How to create a password generator?
I don't get it ...
Here is the main question:
I need to use those ranges for making a password and putting it not via MsgBox, but via SendInput.And how about passwords made from just lowercase, UPPERCASE and numbers?
48-57 (the digits 0-9)
65-90 (uppercase A-Z)
97-122 (lowercase a-z)
How to make Random choose symbols from those three ranges?
Re: How to create a password generator?
how long are these passwords going to be? Personally I go for ten characters or more.
v1: biga.ahk | array.ahk | string-similarity | graphicsearch.ahk | midday.ahk | expect.ahk
Re: How to create a password generator?
I would also implement some options for those: when there would be a need of 8 symbols, I would press a needed combination + digit 8, when I would need 15 symbols, would press needed combination + 15, etc ...
Re: How to create a password generator?
Here is how you can specify each type, and get random arrangements.
Code: Select all
F3::Send % newPass(2, 5, 3) "`n"
newPass(lower, upper := 0, digits := 0) {
Static set := [[97, 122], [65, 90], [48, 57]]
str := []
For type, qty in [lower, upper, digits] ; Loop through the three types of characters
Loop, %qty% { ; Generate number of characters of this type
Random, rand, set[type].1, set[type].2 ; Set boundaries for random numbers
str.Push(Chr(rand)) ; Push the character onto the stack
}
Loop, % str.Count() { ; Loop according to the stack size
Random, rand, 1, str.Count() ; Pick a random position within the remaining characters
pass .= str.RemoveAt(rand) ; Remove character; append to the password
}
Return pass
}
Re: How to create a password generator?
awesome!mikeyww wrote: ↑25 Apr 2021, 05:43Here is how you can specify each type, and get random arrangements.
Code: Select all
F3::Send % newPass(2, 5, 3) "`n" newPass(lower, upper := 0, digits := 0) { Static set := [[97, 122], [65, 90], [48, 57]] str := [] For type, qty in [lower, upper, digits] ; Loop through the three types of characters Loop, %qty% { ; Generate number of characters of this type Random, rand, set[type].1, set[type].2 ; Set boundaries for random numbers str.Push(Chr(rand)) ; Push the character onto the stack } Loop, % str.Count() { ; Loop according to the stack size Random, rand, 1, str.Count() ; Pick a random position within the remaining characters pass .= str.RemoveAt(rand) ; Remove character; append to the password } Return pass }
-
- Posts: 141
- Joined: 24 Jul 2019, 15:27
Re: How to create a password generator?
Code: Select all
F3::
Length = 17 ; length of the password
Characters = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890~!@#$^&*() ; included characters
Loop, 10 ; how many password ganerate
{
Passwords .= "`r`n"
UsedRandomNumbers =
Loop %Length%
{
GetNewRandomNumber:
Random, RandomNumber, 1, % StrLen(Characters)
if RandomNumber in %UsedRandomNumbers%
goto GetNewRandomNumber
UsedRandomNumbers := ((UsedRandomNumbers)(RandomNumber)",")
Passwords .= SubStr(Characters, RandomNumber, 1)
}
}
FileDelete, %A_Temp%\Passwords.txt
FileAppend, % SubStr(Passwords, 3), %A_Temp%\Passwords.txt
Run, notepad.exe "%A_Temp%\Passwords.txt"
Re: How to create a password generator?
seems reasonable
Code: Select all
A := new biga() ; requires https://github.com/biga-ahk/biga.ahk
allCharOptions := "abcdefghijklmnopqrstuvwxyzAbCDEFGHIJKLMONPQRSTUVWXYZ0123456789"
F1::
sendInput, % fn_generatPassword(allCharOptions, 16)
; => "8g8YUWTRaltMwNWe"
return
fn_generatPassword(param_map, param_length:=8)
{
; turn string argument into an array
chars := strSplit(param_map)
; loop as many times as needed to achieve the password length
loop, % param_length {
; append a random element to the password string
password .= biga.sample(chars)
}
return password
}
v1: biga.ahk | array.ahk | string-similarity | graphicsearch.ahk | midday.ahk | expect.ahk
Re: How to create a password generator?
I wrote a Password Generator: viewtopic.php?f=83&t=95321
[AHK] v2.0.18 | [WIN] 11 Pro (23H2) | [GitHub] Profile
Who is online
Users browsing this forum: Bing [Bot] and 28 guests