944,113 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 4085
  • Java RSS
Apr 4th, 2006
0

Java Cipher Help??

Expand Post »
Hi Guys, wonder if any one can help??

I have been asigned some home work to make a CaesarCipher class, listed below, where by there is a test class below which would need to be passed to it. I have figured out the first bit but cant debugg and get it to work. Hope you can help

Tom Keys

//First Class file

public class CaesarTest {
public static void main( String[] args ) {
CaesarCipher c = new CaesarCipher( 10 );
String output;
output = c.encrypt( "The quick brown fox jumps over the lazy dog" );
System.out.println( output );
output = c.decrypt( output );
System.out.println( output );
}
}





//Second Class File


public class CaesarCipher {

private int key;


public CaesarCipher( int inKey ) {
key = inKey;
}

public String encrypt( String s ) {
int lengthOfString = s.length();
StringBuffer encrypted = new StringBuffer();
for (int i=0; i< lengthOfString; i++) {
char tempChar = s.charAt(i);
encrypted.append( encrypt( tempChar ) );

}
return i;

}

//public String decrypt( String s ) {
// Decrypt the argument a character at a time & return the result
//}



private char encrypt( char c ) {
c = charact;

//Encrypt the argument & return the result


//char charact = stringName.getCharAt(i);
charact = charact + key;
outString.append(charact);



}




//private char decrypt( char c ) {
// Decrypt the argument & return the result
//}

}
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
tomkeys2006 is offline Offline
3 posts
since Apr 2006
Apr 5th, 2006
0

Re: Java Cipher Help??

What's the problem? I assume it's with the output? You need to check the ascii ranges for viewable characters. There's no need to encrypt new line characters and those out of the viewable range.
Reputation Points: 113
Solved Threads: 19
Postaholic
server_crash is offline Offline
2,108 posts
since Jun 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Really Beginning problem.
Next Thread in Java Forum Timeline: Warning Message DialogBox





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC