Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
48 views

Project 17

You have been hired by the CIA to write a Crypto class with encrypt and decrypt methods. The encrypt method replaces certain letters in a string with other strings. The decrypt method performs the reverse process to return the original string. A Tester class is provided to test that the encrypt and decrypt methods work properly by encrypting and then decrypting a sample sentence.

Uploaded by

api-307094923
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views

Project 17

You have been hired by the CIA to write a Crypto class with encrypt and decrypt methods. The encrypt method replaces certain letters in a string with other strings. The decrypt method performs the reverse process to return the original string. A Tester class is provided to test that the encrypt and decrypt methods work properly by encrypting and then decrypting a sample sentence.

Uploaded by

api-307094923
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Project 17 Encryption/Decryption

You have just been hired by the CIA as a programmer in the encryption department. Your job is to
write a class called Crypto. One method, encrypt, will accept a String that represents the sentence to
be encrypted. It will return a String that is the sentence with all vs (big or small) replaced with
ag,r , all ms (big or small) with ssad, all gs (big or small) with jeb..w, and all bs (big or
small) with dug>?/.
The class contains another method, decrypt, that accepts a String that represents the sentence to be
decrypted. In this method, the reverse process described above is performed. It returns a String that
is the original sentence before encryption.
Use the following Tester class to ensure that your methods work.
import java.io.*;
import java.util.*;
public class Tester
{
public static void main(String args[])
{
Scanner kbReader = new Scanner(System.in);
System.out.print(Enter a sentence that is to be encrypted: )
String sntnc = kbReader.nextLine();
System.out.println(Original sentence = + sntnc);
Crypto myCryptObj = new Crypto();
String encryptdSntnc = myCryptObj.encrypt(sntnc);
System.out.println(Encrypted sentence = + encryptdSntnc);
String decryptdSntnc = myCryptOjb.decrypt(encryptdSntnc);
System.out.println(Decrypted sentence = + decryptdSntnc);
}
}
Test with this sentence: This is a very big morning. After running your program, your screen
should appear as follows:
Enter a sentence that is to be encrypted: This is a very big morning.
Original sentence = This is a very big morning.
Encrypted sentence = This is a ag,rery dug>?/ijeb..w ssadorninjeb..w.
Decrypted sentence = This is a very big morning.

You might also like