I NEED HELP ASAP. Please find any errors in the code, let me know if there should be anything removed or added specifically. If something needs to be added please specify the exact code needed. I am looking for ways I can make this code better or analyze what I can remove.
CODE:
rand('twister', sum(100*clock));
%{
Define data sets
%}
% Edit these sets as needed
up = ['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'];
low = ['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'];
nums = ['0' '1' '2' '3' '4' '5' '6' '7' '8' '9'];
special = ['!' '@' '#' '$' '%' '^' '&' '*' '_' '-' '+' '=' '' ':' ';' '.' ','];
%{
Prompt for minimum password length
%}
minimum = input('Please enter the minimum password length: ');
%{
Prompt for maximum password length
%}
maximum = -1;
while (maximum < minimum)
maximum = input('Please enter the maximum password length: ');
end
%{
Calculate password length
%}
pass_length = ceil((maximum - minimum + 1) * rand) + minimum - 1;
fprintf('\nThe password length will be %d characters long.\n\n', pass_length);
%{
Prompt for minimum number of uppercase letters
%}
requirement(1) = inf;
while (requirement(1) > pass_length)
requirement(1) = input('Please enter the minimum number of uppercase characters: ');
end
req1 = requirement(1);
%{
Prompt for minimum number of lowercase letters
%}
requirement(2) = inf;
while (requirement(2) > (pass_length - requirement(1)))
requirement(2) = input('Please enter the minimum number of lowercase characters: ');
end
req2 = requirement(2);
%{
Prompt for minimum number of numbers
%}
requirement(3) = inf;
while (requirement(3) > (pass_length - requirement(1) - requirement(2)))
requirement(3) = input('Please enter the minimum number of numerical characters: ');
end
req3 = requirement(3);
%{
Prompt for minimum number of special characters
%}
requirement(4) = inf;
while (requirement(4) > (pass_length - requirement(1) - requirement(2) - requirement(3)))
requirement(4) = input('Please enter the minimum number of special characters : ');
end
req4 = requirement(4);
%{
Compute password
%}
% character counter
i = 1;
password = '';
up_count = 0; low_count = 0; nums_count = 0; special_count = 0;
while i <= pass_length
% produce a random number from 1 to 4
select = ceil((4) * rand);
if (requirement(select) > 0) || ((pass_length - i + 1 - requirement(1) - requirement(2) - requirement(3) - requirement(4)) > 0)
switch select
% uppercase
case 1
password(i) = up(ceil((length(up)) * rand));
up_count = up_count + 1;
% lowercase
case 2
password(i) = low(ceil((length(low)) * rand));
low_count = low_count + 1;
% number
case 3
password(i) = nums(ceil((length(nums)) * rand));
nums_count = nums_count + 1;
% special character
case 4
password(i) = special(ceil((length(special)) * rand));
special_count = special_count + 1;
end
i = i + 1;
% if it satisfies a requirement decrement
if (requirement(select) > 0)
requirement(select) = requirement(select) - 1;
end
end
end
%{
Display results
%}
if (req1 <= up_count) && (req2 <= low_count) && (req3 <= nums_count) && (req4 <= special_count)
fprintf('\nAll requirements satisfied!\n');
fprintf(' - %d uppercase characters\n', up_count);
fprintf(' - %d lowercase characters\n', low_count);
fprintf(' - %d numerical characters\n', nums_count);
fprintf(' - %d special characters\n\n', special_count);
fprintf('The password is: %s\n\n', password);
else
disp('One or more requirements were not satisfied!');
end
Dear client"
I have read your project description about" MATLAB Project Code (Random Password Generator) -- 2" and I'm confident i can do this project for you perfectly.I still have a few questions. please leave a message on my chat so we can discuss the budget and deadline of the project.
Thanks.
..If this project is deleted hire me directly in my profile https://www.freelancer.com/u/johnwanjiku
---I CAN DO IT----
I read your project carefully and I can help you.
I am Matlab expert. and I have 10+years experience in c, c++,etc.
u can see my review.
please chat with me.
thank you
i m working in Matlab programming and i build many projects and dissertation in it. i have good knowledge for mathematics and i m a good programmer to do it. plz give me a chance to work with u
Hey there,
I am a computer engineer and have completed various projects in Matlab.
I can easily help you with your code and surely suggest you the best options to optimize your code.
Thankyou!