Skip to Main Content

Java Security

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Caesar Cipher and non printing ascii

843810Nov 28 2004 — edited Nov 29 2004
I am writing a program to implements the caesar cipher. For the program I am using ASCII code so my encryption algorithm is:

c = (p + k) mod 128

The only problem is, is that depending on the characters being encrypted and depending on the key I use some of the characters are encrypted to non-printing ascii characters such as 'del'.

So my code reads in the plain text from a file converts each character to ascii, encrypts each character using the key. It then writes the encrypted ascii values to a file as text (i.e. the character equivalent of the ascii).

If I do then encounter a non-printing ascii value it is written to the file as a square shape. Is there any way I can get around this?

Thanks for your help on the matter.

Wallace
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 27 2004
Added on Nov 28 2004
2 comments
528 views