23.11.2014 Views

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

In Code Fragment 3.9, we give a simple, complete <strong>Java</strong> class for perform<strong>in</strong>g the<br />

Caesar cipher, which uses the approach above <strong>and</strong> also makes use of conversions<br />

between str<strong>in</strong>gs <strong>and</strong> character arrays. When we run this program (to perform a<br />

simple test), we get the follow<strong>in</strong>g output:<br />

Encryption order = DEFGHIJKLMNOPQRSTUVWXYZABC<br />

Decryption order = XYZABCDEFGHIJKLMNOPQRSTUVW<br />

WKH HDJOH LV LQ SODB; PHHW DW MRH'V.<br />

THE EAGLE IS IN PLAY; MEET AT JOE'S.<br />

Code Fragment 3.9:<br />

for the Caesar cipher.<br />

A simple, complete <strong>Java</strong> class<br />

157

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!