lundi 20 août 2018

Windows Batch - Randomly select variable to create password

I'm trying to create a little batch to generate passwords from different variable. Each variable got 4 characters.

The user will be asked ho many characters does his password need : 4/8/12/16/20/24 The script will generate the password from the different variable.

Here's how I see it :

I set my variable :

  • set 1=@3Cn
  • set 2=&m5K
  • set 3=2m?Z
  • set 4=@Eq6
  • set 5=N_8z
  • set 6=6:Ug

Asking the user how many characterz he want

Go to the password generator section And depending of the choice of the user, the batch will randomly generate number and choose the variable that are equal to the random number like this :

  • Loop until password length != user choice
  • Generate ramdom number
  • Shearch for variable=random number
  • add the variable into a new one (concatenate the selected variable into it)

It's this last part I can't figure it out. How to find the variable that are equal to my random number and add the variable in a new variable ?

I hope I explained my problem clearly and will be waiting for your help

Thanks in advance !




Aucun commentaire:

Enregistrer un commentaire