Generating random string in used in cryptography and it is very important in our day to day programming to generate a random password generation, random username access or login .. etc., To generate a random string with other characters you can add those characters to array1.
#!/bin/bash MAXSIZE=8 array1=( w e r t y u p a s d f h j k z x c v b m Q W E R T Y U P A D F H J K L Z X C V B N M 2 3 4 7 8 1 5 6 9 ) MODNUM=${#array1[*]} pwd_len=0 while [ $pwd_len -lt $MAXSIZE ] do index=$(($RANDOM%$MODNUM)) password="${password}${array1[$index]}" ((pwd_len++)) done echo $password
Advertisements
Hi
Nice script. Why did you select exactly those characters? Uppercase “o” is hard to distinguish from zero, but why is i.e. uppercase “s” missing?
LikeLike
Thanks, this has helped me a lot !
LikeLike
đŸ˜€
LikeLike