Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Create a class called Cipher. Make the constructor accept some text and a key. Encrypt the given text using the key. Use the following cipher:
Create a class called Cipher. Make the constructor accept some text and a key. Encrypt the given text using the key.
Use the following cipher:
Take the key and mod it by Example: a key of becomes
If the character is a letter, shift it by the key, but 'wrap around' the alphabet if necessary.
If the character is not a letter, then shift it by the key but do not wrap.
Check the test cases for example.
Make getters to support the CipherDemo. Also, make two custom Exceptions called UselessKeyException and EmptyPlainText. In your constructor, throw UselessKeyException if the key is divisible by and throw EmplyPainText if the plain text is zero characters.
Test Case
Enter some text to encrypt
abcENTER
Enter a key
ENTER
Plain text: abc
Cipher text: bcd
Key:
Test Case
Enter some text to encrypt
ENTER
Enter a key
ENTER
Error: Nothing to encrypt!
Test Case
Enter some text to encrypt
ENTER
Enter a key
ENTER
Error: Nothing to encrypt!
Test Case
Enter some text to encrypt
BitCoin is cool but it has its problems.ENTER
Enter a key
ENTER
Error: Key is divisible by That's a bad key!
Useless key:
Test Case
Enter some text to encrypt
BitCoin is cool but it has its problems.ENTER
Enter a key
ENTER
Plain text: BitCoin is cool but it has its problems.
Cipher text: PwhQcwbwgqcczpih.whvog.whgdfcpzsag
Key:
Test Case
Enter some text to encrypt
BitCoin is cool but it has its problems.ENTER
Enter a key
ENTER
Plain text: BitCoin is cool but it has its problems.
Cipher text: NufOauz,ueoaax,ngfuftme,ufe,bdanxqye:
Key:
Test Case
Enter some text to encrypt
BitCoin is cool but it has its problems.ENTER
Enter a key
ENTER
Plain text: BitCoin is cool but it has its problems.
Cipher text: LsdMysxscmyyvledsdrkcsdczbylvowc
Key:
Test Case
Enter some text to encrypt
BitCoin is cool but it has its problems.ENTER
Enter a key
ENTER
Plain text: BitCoin is cool but it has its problems.
Cipher text: JqbKwqvqakwwtjcbqbpiaqbaxzwjtmua
Key:
Test Case
Enter some text to encrypt
BitCoin is cool but it has its problems.ENTER
Enter a key
ENTER
Plain text: BitCoin is cool but it has its problems.
Cipher text: HozIuot&oy&iuur&haz&oz&ngy&ozy&vxuhrksy
Key:
Test Case
Enter some text to encrypt
With computer science, you can work in any industry.ENTER
Enter a key
ENTER
Error: Key is divisible by That's a bad key!
Useless key:
Test Case
Enter some text to encrypt
With computer science, you can work in any industry.ENTER
Enter a key
ENTER
Plain text: With computer science, you can work in any industry.
Cipher text: Eqbpkwuxcbmzakqmvkmgwckivewzsqvivgqvlcabzg
Key:
Test Case
Enter some text to encrypt
With computer science, you can work in any industry.ENTER
Enter a key
ENTER
Error: Key is divisible by That's a bad key!
Useless key:
Test Case
Enter some text to encrypt
With computer science, you can work in any industry.ENTER
Enter a key
ENTER
Error: Key is divisible by That's a bad key!
Useless key:
Test Case
Enter some text to encrypt
With computer science, you can work in any industry.ENTER
Enter a key
ENTER
Plain text: With computer science, you can work in any industry.
Cipher text: Frcqlxvydcnablrnwlnhxdljwfxatrwjwhrwmdbcah
Key:
Test Case
Enter some text to encrypt
With computer science, you can work in any industry.ENTER
Enter a key
ENTER
Plain text: With computer science, you can work in any industry.
Cipher text: Zlwk#frpsxwhu#vflhqfh#brx#fdq#zrun#lq#dqb#lqgxvwub
Key:
Test Case
Enter some text to encrypt
Hello, my secret password is SIMCITY! Don't tell anyone! I've used this for days.ENTER
Enter a key
ENTER
Plain text: Hello, my secret password is SIMCITY! Don't tell anyone! I've used this for days.
Cipher text: EbiilCjvpbzobqmxpptloafpPFJZFQVAlkqqbiixkvlkbFsbrpbaqefpcloKGGaxvpE
Key:
Test Case
Enter some text to encrypt
XYZENTER
Enter a key
ENTER
Plain text: XYZ
Cipher text: YZA
Key:
Test Case
Enter some text to encrypt
ABCENTER
Enter a key
ENTER
Plain text: ABC
Cipher text: BCD
Key:
Test Case
Enter some text to encrypt
xyzENTER
Enter a key
ENTER
Plain text: xyz
Cipher text: yza
Key:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started