I need help fixing up my password generator

3 visualizaciones (últimos 30 días)
Madeleine
Madeleine el 1 de Mayo de 2014
Respondida: the cyclist el 1 de Mayo de 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

Respuesta aceptada

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

Más respuestas (0)

Categorías

Más información sobre MATLAB Coder en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by