Results 1 to 3 of 3

Thread: Java - Encrypt and Decrypt a file

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2007
    Posts
    341

    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.

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    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

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2007
    Posts
    341

    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
  •  



Click Here to Expand Forum to Full Width