[Last Call] Learn how to a build a cloud-first strategyRegister Now


Encrypt and decrypt a file using a DES algorithm

Posted on 2011-04-21
Medium Priority
Last Modified: 2012-05-11
I am learning about Encryption and Decryption in VB.Net this time...
i found several articles and tutorials.
The one i use for sample purposes is http://www.vb-helper.com/howto_net_des_file.html
The example creates an output file that is encrypted..although the original file can be accessed..
I need some help here...i want my original file to be encrypted...
LVL 83

Accepted Solution

CodeCruiser earned 1000 total points
ID: 35442016
I think you have to move the original file to a temp location and then recreate it at original location. The temp file can then be deleted.

Expert Comment

ID: 35442191
how about you just enrypt the original by either using the cipher command in a command prompt or encrypting it through the properties of the file. properties general tab advanced button and check encrypt this file
LVL 18

Author Comment

by:John (Yiannis) Toutountzoglou
ID: 35442219
1.i've created an XML file in C:\Sqvars.xml
2.I have to move this file in temp directory
The Following Code Creates a temp file in my temp directory

Dim sTempFile As String = System.IO.Path.GetTempFileName()
        Dim fsTemp As New System.IO.FileStream(sTempFileName, IO.FileMode.Create)]

Open in new window

3.the output encrypt file should have the same name with my original one  (?)
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

LVL 18

Author Comment

by:John (Yiannis) Toutountzoglou
ID: 35442254
I dynamically creates this xml file...The encrypt option is unavailiable....
LVL 18

Author Comment

by:John (Yiannis) Toutountzoglou
ID: 35442488
Got it...
1.i move the original file to a temp location
2.I create encrypted File to my specific Location
and i do the opposite when i need the data of the file....
   Dim FileToMove As String
             Dim MoveLocation As String
             Dim sTempFileName As String = System.IO.Path.GetTempFileName()
        FileToMove = "C:\SqVars.xml"
        MoveLocation = System.IO.Path.GetTempPath & "SqVars.xml"
        If System.IO.File.Exists(FileToMove) = True Then
            System.IO.File.Move(FileToMove, MoveLocation)
        End If 

Open in new window

LVL 21
ID: 35442494
I would do this:

1)  create the XML file as temp file with a temp name. Not the name you want
2) encrypt  the temp file to a new fiel with the name you want.
3) delete the temp file that is not encrypted
LVL 21
ID: 35442518
How do you now the file is encrypted  if the name is the same for both the decrypted and encrypted version?
LVL 18

Author Comment

by:John (Yiannis) Toutountzoglou
ID: 35442521
TheHiTechCoach thank you for your post...
Already got it by CodeCruiser's Guideline..
Your comment is also helpfull that needs less actions..

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Screencast - Getting to Know the Pipeline
Suggested Courses

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question