jQuery in Action, 2nd edition*
The moose likes Java in General and the fly likes How to encrypt a string &save it to a file?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to encrypt a string &save it to a file??" Watch "How to encrypt a string &save it to a file??" New topic
Author

How to encrypt a string &save it to a file??

netharam ram
Ranch Hand

Joined: Aug 09, 2001
Posts: 202
Hi, I want to encrypt a text & save it to file,which should not be human readable or easily understandable.In my application I want to read the file & decrypt the text.Please reply with some code if possible.
Happy middling with java.
Netharam.
Roseanne Zhang
Ranch Hand

Joined: Nov 14, 2000
Posts: 1953
Blowfish symmetric algorithm
It is opensource, better than DES, easy to use, fit your needs perfectly. Don't forget to acknowledge them!
Thanks!
Roseanne
Need Java real project experience? Join our project team here!
[ April 29, 2002: Message edited by: Roseanne Zhang ]
Thomas Smets
Ranch Hand

Joined: Dec 11, 2001
Posts: 111
RSA encryption
found on another forum.
Also,
  • Quick link to RSA
  • XML encryption, got the news froma Dutch guy working at ABN that IBM developped a Encryption / Decryption tool for XML (not free) which allows you to encode part of an XML file


  • Thomas,


    Thomas Smets
    Just another developper
    Roseanne Zhang
    Ranch Hand

    Joined: Nov 14, 2000
    Posts: 1953
    Originally posted by netharam ram:
    Hi, I want to encrypt a text & save it to file,which should not be human readable or easily understandable.In my application I want to read the file & decrypt the text.Please reply with some code if possible.

    From my understanding of the question, the encryption/decryption is done by the same party, correct me if I am wrong, symmetric algorithm is the way to go. Blowfish is a new and better symmetric encryption algorithm. DES is another one... I used Blowfish encryption, our product has just shipped to Disney.
    RSA is for encrypting by one party and decrypting by another party. RSA or other Public/Private Key pair system (e.g. D-H Public-Key Directory) solved the famous key transportation problem. Read a very good introductory from here: Introduction To Cryptography
    MD5 or other one-way digest encryption algorithm is for encrypting password, which means you never want to decrypt it back. I used it on our project team login page for a little more than a year now...
    Different encryption algorithms solve different problems and are used for different purposes...
    [ May 05, 2002: Message edited by: Roseanne Zhang ]
    Charlie Hubbard
    Greenhorn

    Joined: Apr 30, 2002
    Posts: 6
    Originally posted by netharam ram:
    Hi, I want to encrypt a text & save it to file,which should not be human readable or easily understandable.In my application I want to read the file & decrypt the text.Please reply with some code if possible.
    Happy middling with java.
    Netharam.

    You can use JCE for any sort of encryption that you would like to perform. Look at the JCE documentaion in the appendicies for an example of PBE (password based encryption). That you get you started.
    charlie
    Charlie Hubbard
    Greenhorn

    Joined: Apr 30, 2002
    Posts: 6
    Here is the URL for JCE
    http://java.sun.com/products/jce/
    If you're running JDK1.4 you don't need to download it.
    charlie
    Roseanne Zhang
    Ranch Hand

    Joined: Nov 14, 2000
    Posts: 1953
    JCE are just interfaces. Sun provider does not provide any Sysmmetric algorithms, only RSA and MD5 etc.. You still need the Encryption algorithm providers.
    Been there, and done that.
    Roseanne Zhang
    Ranch Hand

    Joined: Nov 14, 2000
    Posts: 1953
    If you download the BlowfishJ, and try their sample code, then you will find how easy to use it. We wasted so much time to discuss it, it is enough to get the job done already.
    Mark Herschberg
    Sheriff

    Joined: Dec 04, 2000
    Posts: 6037
    Originally posted by Roseanne Zhang:
    JCE are just interfaces. Sun provider does not provide any Sysmmetric algorithms, only RSA and MD5 etc.. You still need the Encryption algorithm providers.
    Been there, and done that.


    Easy enough, just go to Cryptix or Bounce Castle for providers.
    --Mark
    Junaid Bhatra
    Ranch Hand

    Joined: Jun 27, 2000
    Posts: 213
    Originally posted by Roseanne Zhang:
    JCE are just interfaces. Sun provider does not provide any Sysmmetric algorithms, only RSA and MD5 etc.. You still need the Encryption algorithm providers.
    Been there, and done that.

    On the contrary, I think the Sun provider that ships with the JCE(assuming you are within the US) does provide implementations of the symmetric-key DES and BlowFish algorithms. It does not provide an implementation of the RSA algorithm though...
    [ May 01, 2002: Message edited by: Junaid Bhatra ]
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: How to encrypt a string &save it to a file??
     
    Similar Threads
    How to hide Username Password in the browser
    Is it possible to convert a key to string (like to store it in a file)?
    encrypt and decrypt a file of size about 10 mb
    Encryption-decryption file problem
    password protecting a MS word Document