Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a utility class that encrypts and decrypts names. Your utility class should contain a cache of previously encrypted names so that if you encrypt

Write a utility class that encrypts and decrypts names.

Your utility class should contain a cache of previously encrypted names so that if you encrypt or decrypt a name, the cache is checked first to see if the name is there. You can implement the cache any way you would like.

Encryption algorithm: o Split the name into two equal parts. if it is an odd number length, then add a # at the end of the name to make the length even. Example:Amin -> "Am""in" Example:Vimal -> "Vim""al#"o Reverse the parts and concatenate back into one string Example: Amin -> Am in -> inAm Example: Vimal -> Vim al# -> al#Vimo Decryption would reverse this algorithm and remove the '#' symbol if present.

Encryption method: o If the non-encrypted name is in the cache, just return the encrypted name o Otherwise encrypt the name per the encryption algorithm, add to the cache, and return the encrypted name

Decryption method: o If the encrypted name is in the cache, return the non-encrypted name o Otherwise decrypt the name by reversing the encryption algorithm, add to the cache, and return the non-encrypted name

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 Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions

Question

per cent of the sales). What is the reason for that?

Answered: 1 week ago