Effacer les filtres
Effacer les filtres

I need help fixing up my password generator

1 vue (au cours des 30 derniers jours)
Madeleine
Madeleine le 1 Mai 2014
So far my program lets a user input the range of how many characters they want in the password, and also input how many passwords they want generated. My program also checks if the first element of the password is a letter, if it isn't an error is returned to the screen. I have started checking if there is at least one lower case letter in the password as well, but it doesn't seem to be working. All my code is below and I'd really appreciate some help :)
function password_generator
s = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
sLength = input('What is your password range: ');
Repeats = input('How many passwords do you want generated: ');
numRands = length(s);
for number_of_passwords = 1: Repeats
[Random_Password] = s(round(rand(1,randi(sLength))*numRands));
disp(Random_Password);
[check] = isstrprop(Random_Password, 'alpha')
if check(1) == 1
else
error('The first element of password is not a letter');
end
[check2] = isstrprop(Random_Password,'lower')
if check2 == 1
else
error('There are no lower case letters in this password')
end
end
end

Réponse acceptée

the cyclist
the cyclist le 1 Mai 2014
If I understand your intent correctly, I think you want your second check to be
if any(check2 == 1)

Plus de réponses (0)

Catégories

En savoir plus sur Embedded Coder dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by