Results 1 to 6 of 6

Thread: Encrypt a file then Read it

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2010
    Posts
    58

    Encrypt a file then Read it

    So I have a connection string which is read from a basic text file. This string contains a password. Is there anyway to encrypt this text file so that anyone can't just open it up and read it. The program will still be able to read it.

  2. #2
    Lively Member
    Join Date
    Jan 2010
    Location
    United Kingdom
    Posts
    115

    Re: Encrypt a file then Read it

    Search the forum for Encrypt Decrypt. There are loads of posts relating to file encryption and decryption.
    Regards
    Colin

    If my comments helped please remember to add to my reputation using Rate This Post.

    If your problem has been resolved please mark the thread resolved using the "Mark Thread Resolved" link in thread tools.

    CodeBank Submissions: 1) WebBrowser - Delete cookies etc 2) Import My.Settings from previous build version

  3. #3
    Fanatic Member stlaural's Avatar
    Join Date
    Sep 2007
    Location
    Quebec, Canada
    Posts
    683

    Re: Encrypt a file then Read it

    Yes, it is possible. In order to encrypt and decrypt a file you will need to use the System.Security.Cryptography Namespace.

    I don't have any code sample right now as I'm at work but I'm pretty sure you can find a lot by a simple google search, or maybe someone else will post some.

    Basically what you will need to do is choose a cryptography Symmetric Algorithm use it encrypt and decrypt your file. Your application will need to know the password that was used to encrypt the file to be able to decrypt it.

    here's a good example
    Alex
    .NET developer
    "No. Not even in the face of Armageddon. Never compromise." (Walter Kovacs/Rorschach)

    Things to consider before posting.
    Don't forget to rate the posts if they helped and mark thread as resolved when they are.


    .Net Regex Syntax (Scripting) | .Net Regex Language Element | .Net Regex Class | DateTime format | Framework 4.0: what's new
    My fresh new blog : writingthecode, even if I don't post much.

    System: Intel i7 920, Kingston SSDNow V100 64gig, HDD WD Caviar Black 1TB, External WD "My Book" 500GB, XFX Radeon 4890 XT 1GB, 12 GBs Tri-Channel RAM, 1x27" and 1x23" LCDs, Windows 10 x64, ]VS2015, Framework 3.5 and 4.0

  4. #4
    Frenzied Member
    Join Date
    Jul 2009
    Posts
    1,103

    Re: Encrypt a file then Read it

    are you aware of the basic concepts of the cryptography such as what are the features of symmetric key algorithms,assymetric key algorithm,etc etc

    if not then i think there wont be anyone who will guide you from the very basics....i will suggest you to have a google search on this topic,decide whether you want to use symmetic or assymetric key algorithm according to your need,then have a go at that particular algorithm,try to implement it in your code and then post the particulars which will cause you problem...

    Then only you will get some good guidance.....


    If you find my reply helpful , then rate it

  5. #5
    Frenzied Member
    Join Date
    Jul 2009
    Posts
    1,103

    Re: Encrypt a file then Read it

    Rijndael is a symmetric key algorithm.....keep it in mind before having a go at the above link

    If you find my reply helpful , then rate it

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: Encrypt a file then Read it

    Does it need to be in a text file? Connections strings are generally stored in the config file, which supports encryption inherently. Follow the CodeBank link in my signature and check out my Protected Configuration thread for more info.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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