I need help fixing up my password generator
3 views (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
the cyclist
on 1 May 2014
If I understand your intent correctly, I think you want your second check to be
if any(check2 == 1)
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!