1

I want to write the java program which creats the text file with the password protection. That means when the user opens the file it should ask the password to open the file. Can any one please give me some idea how can I do this?

Java-Seekar
  • 1,720
  • 5
  • 30
  • 52

1 Answers1

1

Simple password protection is not possible, because (as @MaVRoSCy points out) the OS is not going to stop some other application from ignoring your password protection scheme.

What you could do is to encrypt the text file using a password as the encode / decode key. However, this approach is vulnerable to brute-force attack, and attack using "rainbow tables".

Encryption using proper keys with a large amount of entropy is a much better approach.


Anyway, this Question is a good place to start: Java 256-bit AES Password-Based Encryption

Community
  • 1
  • 1
Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
  • an AES brute force attack would be impractical http://crypto.stackexchange.com/questions/1145/how-much-would-it-cost-in-u-s-dollars-to-brute-force-a-256-bit-key-in-a-year – kyle k Aug 30 '13 at 06:29
  • 1
    Nonsense! A system that uses passwords as the "secret" is only as good as the passwords ... no matter what encryption algorithm you use. Please read the Question properly. – Stephen C Aug 30 '13 at 06:32
  • I will, thanks for adding that extra line to your answer. – kyle k Aug 30 '13 at 06:54