Java - Encrypt and Decrypt a file
Please I need some assistance with a simple code to Enncrypt and Decrypt 26letters of the Alphabet( A to Z) contained in a file called "SecretFile".
Example: File SecretFile contains: ABCDEFGHIJKLMNOPQRSTUVWXYZ.
I really don't know where to start:
so far I have:
Code:
import java.??????? // what base class do I import for this operation?
imoport java.io.*;
public class Encryptor implements OutputStream
{
private OutputStream mOutput;
public Encryptor(OutputStream);
Char Encrypt(char ch)
{
if ch > 'A' && ch < 'z')
{
int val = (int) ch;
int Aval = (int)'A';
val = (val - Aval + 1)%26 Aval;
return (Char) val;
}
}
}
class Decryptor exends Encryptor
{
I guess I should do the reverse in the above process???????
Any help will be greatly appreciated.
GiftX.
Re: Java - Encrypt and Decrypt a file
You know, Encryption is not something that just happens to a string... you should decide on the Algorithm to use, there are tons of them. Regardless, javax.crypto should be a good start.
Cheers
Re: Java - Encrypt and Decrypt a file
Okay. I understand what you mean, but can you give me an example using Cesar Cipher method or javax.crypto that you mentioned. If knew how to use any, I would be asking for assistance.
Thanks.
GiftX.