Need some help with encryption decryption
Can you help me fill in the blanks in the most basic code you can think of. Please
public class ToolKit {
/* Some Code Removed For Brevity */
public static String lowerCase(String str) {
String lowerT="";
for (int i=0; i<str.length(); i++) {
String ltr=str.substring(i, i+1);
int caseIndex=UPPER_ALPHABET.indexOf(ltr);
if(caseIndex==-1) {
lowerT+=ltr;
} else {
lowerT+=LOWER_ALPHABET.substring(caseIndex, caseIndex+1);
}
}
return lowerT;
}
public static int randomNumber(int min, int max) {
if (max < min) {
int temp=min;
min = max;
max = temp;
}
return ((int)(Math.random()*(max- min + 1)) + min);
}
public static String generateCode(String str) {
String code=ALL_CHARACTERS;
/* Your code HERE */
return code;
}
public static String encrypt(String str,String code) {
// Sample Run:
// str="ABCDEF";
// code="CDABEF"
// encrypted="CDABEF"
String encrypted = "";
/* Your code HERE */
return encrypted;
}
public static String decrypt(String str, String code) {
// str="CDABEF";
// code="CDABEF"
// decrypted="ABCDEF"
String decrypted="";
/* Your code HERE */
return decrypted;
}
public final static String UPPER_ALPHABET="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
public final static String LOWER_ALPHABET="abcdefghijklmnopqrstuvwxyz";
public final static String PUNCTUATION=" ,.!@#$%^&*()[]{};:'\"<>\\-_=+";
public final static String ALL_CHARACTERS=UPPER_ALPHABET+LOWER_ALPHABET+PUNCT UATION
Re: Need some help with encryption decryption
Quote:
Originally Posted by
JP34
Can you help me fill in the blanks in the most basic code you can think of. Please
...
No we shouldn't and we won't. Please understand that we'll be happy to look at your attempts and try to help you come to a solution, but we don't appreciate folks just dumping homework in here and asking us to do it for them. That's not right, that's not how you learn, and that's not what we'll do.
So please show your efforts, ask your question, and we'll be more than happy to help as best we can. If this won't work for you, then we wish you well, but again ask that you not dump your work here.