How to password protect a file in C#

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Salim Zaabi
    New Member
    • Oct 2009
    • 25

    #1

    How to password protect a file in C#

    I have been trying to make a program in c# to password protect a file so nobody can open the file if it has been encrypted by password.

    What I want to do is that after password protecting the file, whenever somebody click to open the file, it will ask him for the password. What is the best way to encrypt it, Is it by XOR or AES?
    Last edited by Niheel; May 9 '10, 11:30 PM. Reason: punctuation, grammar, spelling
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    Just .zip it and assign a password when you .zip it

    .rar also supports passwords.

    Both have command line options so you can even call it from within your application

    Comment

    • Monomachus
      Recognized Expert New Member
      • Apr 2008
      • 127

      #3
      Originally posted by Salim Zaabi
      Hi Everyone,

      I have been trying to make a program in c# to password a file, so nobody can open the file if it has been encrypted by password.
      What I want to do is that after passwording the file, whenever somebody click to open the file, it will ask him for the password. And what is the best way to encrypt it, Is it by XOR or AES??
      Take a look at System.Security .Cryptography to learn about cryptography and how to use it with C# and .NET in general.

      Comment

      • Salim Zaabi
        New Member
        • Oct 2009
        • 25

        #4
        Thanks to tlhintoq and Monomachus for replying..

        Comment

        • jkmyoung
          Recognized Expert Top Contributor
          • Mar 2006
          • 2057

          #5
          When you say 'best way', what are you looking for?
          1. Not easily cracked.
          2. Easy to implement.
          3. Quick algorithm.

          Also, what type of file are you trying to encrypt? Can we assume it is binary code?

          There are plenty of encryption algorithms out there. Check out:
          System.Security .Cryptography
          Triple Des is rather popular:
          http://msdn.microsoft.com/en-us/libr...eprovider.aspx

          Moderators: Please merge thread with http://bytes.com/topic/c-sharp/answe...-password-file
          Last edited by Dormilich; Apr 27 '10, 08:43 PM. Reason: done

          Comment

          • Salim Zaabi
            New Member
            • Oct 2009
            • 25

            #6
            thanks jkmyoung,

            What I'm looking for is encryption that is not easy to be cracked, and for any type of files...

            Comment

            Working...