notes intro/old submit AP Problems the dump links

Interface Activity - Encryption


Create a class that implements the encryption interface below. Ideas are:

  1. The encryption will write the phrase backwards (super weak)
  2. The encryption will replace all the I-1 and 1-I, O-0 and 0-O, B-8, 8-B, S-5, 5-S, E-3 and 3-E
  3. The encryption will replace every letter will how far from a it is. Ie b would be 2 and so on. Put commas between letters. Use char(65) to convert the ascii int to a number
  4. For every group of three letters it reorders the first and third. IE scoreboard would be ocsberraod

Messages will be one word, all letters, all lower case

public interface Encryption {
	 * Encrpyt will take in a message and return the message encrypted 
	public String encrypt (String message);
	 * Decrypt will take in an encrypted message and return the message decoded
	public String decrypt (String encryptedMessage);

	 * This will return some info of the encryption method - it should include your names and if you want a hint or teaser
	public String encryptionInfo();
Test it with code below (change Borland to whatever your is called):
	public static void main(String[] args) { 
	    // TODO Auto-generated method stub 
	    Encryption theEncryption=new BorlandsEncrypt();
	    String originalWord="apples";
	    String encrypt=theEncryption.encrypt(originalWord);
	    System.out.println("Encrypting "+originalWord + " is " + encrypt);
	    String decrypt=theEncryption.decrypt(encrypt);
	    System.out.println("Decrypted is" + decrypt);
	    if (!originalWord.equals(decrypt))
	    	System.out.println("THIS ENCRYPTION DOESNT WORK");

Rubric: ( 8 points) - if it is not done in time, you lose 2 points.

  • encrypt works to encrypt a message ( 2.5 points)
  • not instantly obvious how you encrypted (2 points)
  • decrypt works to decrypt that message (2.5 points)
  • description of encryption does its job (1 point)

Bonus points:

  • +1 if no one can decrypt your message
  • +.5 for each message you decrypt of others

For more testing: add to main


	String randomPhrases[]={"sand","confuse","brown123","The bitter stretch preserves the danger.","Cathey Perkins","423 Bombs","There are 219 submarines","207 200 1551"};
for (int i=0;i<randomPhrases.length;i++)	
		String text=randomPhrases[i];
		String en=theEncryption.encrypt(text);
		String dc=theEncryption.decrypt(en);
		if (!dc.equals(text))
		System.out.println(dc +"    :   "+ en);