|
-
Apr 20th, 2008, 01:14 PM
#1
Thread Starter
Hyperactive Member
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.
-
Apr 20th, 2008, 05:05 PM
#2
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
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Apr 21st, 2008, 10:10 AM
#3
Thread Starter
Hyperactive Member
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|