Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

. Use the file attached and complete the following two methods: * encode(String p, String key) that takes a plain text p and encodes it

. Use the file attached and complete the following two methods:

* encode(String p, String key) that takes a plain text p and encodes it to a cipher text by adding the key values to each alphabet character of p, (For example, if p = "attack at dawn" and key is "two", it should be encrypted as "uphuzztxht ppj" because

'a'+'t' = 1+20 = 21 = 'u',

't'+'w' = 20+23 = 16 = 'p',

't'+'o' = 20+15 = 8 = 'h',

'a'+'t' = 1+20 = 21 = 'u',

'c'+'w' = 3+23 = 26 = 'z',

'k'+'o' = 11+15 = 26 = 'z',

' '+'t' = 0+20 = 20 = 't',

'a'+'w' = 1+23 = 24 = 'x',

't'+'o' = 20+15 = 8 = 'h',

' '+'t' = 0+20 = 20 = 't',

'd'+'w' = 4+23 = 0 = ' ',

'a'+'o' = 1+15 = 16 = 'p',

'w'+'t' = 23+20 = 16 = 'p', and

'n'+'w' = 14+23 = 10 = 'j'.)

Note that ' ' = 0, 'a' = 1, 'b' = 2, 'c' = 3, , 'z' = 26.

* decode(String c, String key) that takes a cipher text c and decodes it to a plain text by subtracting the key values from each alphabet character of c.

Assume that the only characters allowed in the plain text are lower-case alphabet letters and blanks

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Fred R. McFadden, Jeffrey Slater, Mary B. Prescott

5th Edition

0805360549, 978-0805360547

More Books

Students also viewed these Databases questions