Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java: please explain this code. Is there a better way to code these two methods? Thanks. /** * Method to make sure the password meets

Java: please explain this code. Is there a better way to code these two methods? Thanks.

/** * Method to make sure the password meets the requirements of one special character, one number and 8 characters * long or more. */ private boolean passwordCheck() { int asciiValueClearPswd[] = new int [100]; int asciiValueClearPswdTwo[] = new int [100]; for(int i = 0; i < clearPassword.length(); i++) { asciiValueClearPswd[i] = clearPassword.charAt(i); for(int j = 0; j < clearPassword.length(); j++) { asciiValueClearPswdTwo[j] = clearPassword.charAt(j); if((asciiValueClearPswd[i] >= 35 && asciiValueClearPswd[i] <= 38) && (asciiValueClearPswdTwo[j] >= 48 && asciiValueClearPswdTwo[j] <= 57) && (clearPassword.length() > 7)) { return true; } }

} return false; }

/** * The method that encrypts the clear password. Uses Vigenere Cipher for Ascii characters */ private void encrypt() {

int j = 0; int encryptNum[] = new int[100]; int asciiValueKey[] = new int[100]; int asciiValueClearPswd[] = new int [100]; byte encryptByte [] = new byte [clearPassword.length()]; for(int i = 0; i < clearPassword.length(); i++) { asciiValueKey[i] = key.charAt(j); asciiValueClearPswd[i] = clearPassword.charAt(i); encryptNum[i] = asciiValueKey[i] - 33; encryptNum[i] = (encryptNum[i] + asciiValueClearPswd[i]) - 90; encryptByte[i] = (byte) encryptNum[i];

if(encryptNum[i] < 33) { encryptNum[i] = (encryptNum[i] - 32) + 122; encryptByte[i] = (byte) encryptNum[i]; } if(key.length() - j == 1) { j = 0; } else { j++; } encryptedPassword = new String(encryptByte); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Theory And Applications 27th Australasian Database Conference Adc 20 Sydney Nsw September 28 29 20 Proceedings Lncs 9877

Authors: Muhammad Aamir Cheema ,Wenjie Zhang ,Lijun Chang

1st Edition

3319469215, 978-3319469218

More Books

Students also viewed these Databases questions

Question

Group Size and Communication

Answered: 1 week ago

Question

Understanding Group Roles

Answered: 1 week ago