need help to generate dynamic password between 8 - 16 characters
i have password generator but i cant get it to generate dynamic length. any idead how to do it?
if [ $# -eq 0 ]; then num=("0" "1" "2" "3" "4" "5" "7" "8" "9") special=("@" "#" "$" "%" "*" "-" "+") upper=(A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) lower=(a b c d e f g h i j k l m n o p q r s t u v w x y z) lower2=${#lower[*]} #${lower[$((RANDOM%lower2))]} upper2=${#upper[*]} #${upper[$((RANDOM%upper2))]} num2=${#num[*]} #${num[$((RANDOM%num2))]} special2=${#special[*]} #${special[$((RANDOM%special2))]} echo "${special[$((RANDOM%special2))]}${num[$((RANDOM%num2))]}${lower[$((RANDOM%lower2))]}${upper[$((RANDOM%upper2))]}${lower[$((RANDOM%lower2))]}${upper[$((RANDOM%upper2))]}${lower[$((RANDOM%lower2))]}${upper[$((RANDOM%upper2))]}" | fold -w 1 | shuf | tr -d '\n' echo fi |
A little off the wall, first can you encap your code in CODE tags, will help from getting a 10ft horizontal scroll bar :)
You can use random to generate a random number between a set of integers, then use that as your length for your password. Having a hard time decyphering this pw generator script so couldnt tell you how to implement in your current code, just thinking about this I might do it slightly different myself. I would just set one array and then use random in a while loop to append a character until it reached the pwlength value. Code:
pwlength=$((RANDOM%16+8)) |
Depending on how those passwords are intended to be used, you might want to filter out obscenities, threats against public officials, remarks that might be considered offensive to Belgians, etc.
How to do that?? Hmmmm,.... You could publish the password candidate on Facebook and see if anyone notices a problem with it. :rolleyes: Or, just don't use any vowels. |
If you want to generate random password between 8-16 character. Try this.
Code:
#!/bin/bash But you want to use your code and you want modification in it, try this. Code:
#/bin/bash |
Not really answering the question but did you check out the binary pwgen?
|
All times are GMT -5. The time now is 01:02 AM. |