Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program in java that prompts the user to enter a String (plaintext), followed by three integers (Ceasar shift value, Affine a value, Affine

Write a program in java that prompts the user to enter a String (plaintext), followed by three integers (Ceasar shift value, Affine a value, Affine b value respectively).

Atbash Cipher

The Atbash cipher is a particular type of monoalphabetic cipher formed by taking the alphabet and mapping it to its reverse, so that the first letter becomes the last letter, the second letter becomes the second to last letter, and so on. For example, the Latin alphabet would work like this:

a

b

c

d

e

f

g

h

i

j

k

l

m

n

o

p

q

r

s

t

u

v

w

x

y

z

z

y

x

w

v

u

t

s

r

q

p

o

n

m

l

k

j

i

h

g

f

e

d

c

b

a

Example(s):

atbash(hello world) twppmaemjpx

Ceasar Cipher

The Ceasar cipher, also known as the shift cipher, is a type of substitution cipher in which each letter in the plaintext is replaced by a letter some fixed number of positions down the alphabet. For example, with a left shift of 3, D would be replaced by A, E would become B, and so on:

Example (left shift 3):

a

b

c

d

e

f

g

h

i

j

k

l

m

n

o

p

q

r

s

t

u

v

w

x

y

z

y

z

a

b

c

d

e

f

g

h

i

j

k

l

m

n

o

p

q

r

s

t

u

v

w

x

Your Ceasar cipher should handle left and right shifts.

Example(s):

ceasar(hello world, -3) ebiilxtloia

ceasar(cheese, 5) hmjjxj

Hint: Use modulus (%) to prevent out of bounds exceptions.

Affine Cipher

The affine cipher is a type of monoalphabetic substitution cipher, wherein each letter in an alphabet is mapped to its numeric equivalent, encrypted using a simple mathematical function, and converted back to a letter. Each letter is enciphered with the function (ax + b) % (alphabet size), where x is the numeric value of the letter and a / b are chosen by the encrypter as a sort of key.

String abc = abced...z ;

0

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

a

b

c

d

e

f

g

h

i

j

k

l

m

n

o

p

q

r

s

t

u

v

w

x

y

z

For example, if a is 10 and b is 4, the letter h would encrypt to u:

(ax + b) % (alphabet size)

(10(7) + 4) % 27 = 20

Example(s):

affine(hello world, 2, 3) rlzzebuekzj

affine(butter, 5, 10) pcyydo

Write your ciphers so that any character that is not a letter or space remains unencrypted.

Sample Output

Welcome to Ciphers!

This program will encrypt your plaintext using the Atbash, Ceasar, and Affine ciphers!

Plaintext: winter is coming!

Ceasar shift value: -6

Affine a value: 24

Affine b value: 7

Atbash: esnhwjasiaymosnu!

Ceasar: qchnzlucmuxigcha!

Affine: wkwewkkkhkbtzkwq!

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

Students also viewed these Databases questions

Question

Find the gravitational force between the sun and Mercury.

Answered: 1 week ago