Closed

MATLAB Project Code (Random Password Generator) -- 2

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

Skills: Matlab and Mathematica, Algorithm, C++ Programming, C Programming, Mathematics

See more: random number generator project free, image processing matlab project code needed, html code random digit generator, fuzzy logic project matlab source code, fuzzy logic matlab project code, random maze generator matlab, project matlab interpolate code, matlab image processing project code, matlab project maker source code wireless, gsm matlab project code, one time password generator code in php, php random password generator script, password generator code project, excel vba random password generator, php random password generator with special characters, random password generator php w3schools, random password generator, random password generator code, random password generator words

About the Employer:
( 0 reviews ) Chula Vista, United States

Project ID: #28216755

5 freelancers are bidding on average $33 for this job

johnwanjiku

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 mess More

$75 USD in 7 days
(9 Reviews)
4.3
globalgo

---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

$20 USD in 1 day
(15 Reviews)
3.4
atechcomputerdhd

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

$35 USD in 1 day
(0 Reviews)
0.0
sayginsa

Hi, I can help you to find errors and make code better. Please contact me for the details. Best Regards, Saim

$15 USD in 2 days
(0 Reviews)
0.0
TalhaKQazi

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!

$20 USD in 1 day
(0 Reviews)
0.0