Creating a password checker using a function
4 ビュー (過去 30 日間)
古いコメントを表示
So im trying to create a password checker that checks for: length of at least 8 characters 1 upper case and 1 lower case but im stuck. This is what i have so far but none of it is working
if true
% code
function [len] = isValidPasswordFUNC(password)
% A function that checks a password to be valid
% Checking the length of the password
len = length(password)
if len < 8
disp('Invalid password is too short');
else
disp('Password is Valid length');
end
Then the script:
if true
% code
close all
clear
clc
password = input('Enter your password: ');
function [len] = isValidPasswordFUNC(password);
end
Thanks any help or a point in a direction is very helpful thanks
0 件のコメント
回答 (1 件)
Guillaume
2018 年 5 月 27 日
編集済み: Guillaume
2018 年 5 月 27 日
Sounds like homework, so I won't give you the solution. I'll just tell you to have a look at isstrprop.
Also, should your checking function return the length of the password or an indication of whether or not the password is valid? The latter would make more sense to me.
参考
カテゴリ
Help Center および File Exchange で Entering Commands についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!