Solved

Help with decrypting file using vb.net

Posted on 2014-10-24
4
124 Views
Last Modified: 2014-10-25
Hi,

How do I modify the code to only decrypt \Data\LinkFiles\LinkFinal.xml instead of all xml files in the folder?

For Each File In Directory.GetFiles(Application.StartupPath & "\Data\LinkFiles")

            Try
                fslinkBEL = New System.IO.FileStream(File, IO.FileMode.Open)
                dtsetlinkBEL = New DataSet
                dtsetlinkBEL.ReadXml(fslinkBEL)
                fslinkBEL.Close()
                Dim sec As New Security
                For t As Integer = 0 To dtsetlinkBEL.Tables.Count - 1
                    For i As Integer = 0 To dtsetlinkBEL.Tables(t).Rows.Count - 1
                        For j As Integer = 0 To dtsetlinkBEL.Tables(t).Columns.Count - 1
                            If Not IsDBNull(dtsetlinkBEL.Tables(t).Rows(i).Item(j)) Then
                                'dtsetlinkBEL.Tables(t).Rows(i).Item(j) = sec.psEncrypt(dtsetlinkBEL.Tables(t).Rows(i).Item(j))
                                dtsetlinkBEL.Tables(t).Rows(i).Item(j) = sec.psDecrypt(dtsetlinkBEL.Tables(t).Rows(i).Item(j))
                            End If
                        Next
                    Next
                    dtsetlinkBEL.WriteXml(File)
                Next
            Catch
                MsgBox(Err.Description & "FileName  " & File)
            End Try
        Next
        MsgBox("All Files Decrypted")

Open in new window

0
Comment
Question by:vcharles
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 36

Accepted Solution

by:
Miguel Oz earned 500 total points
ID: 40403566
You can remove the loop code (lines 1,2 and 23) and insert this line at line 1:
Dim File As String = Application.StartupPath & "Data\LinkFiles\LinkFinal.xml"

Open in new window

The try/catch block code remains the same. I just initialize File variable with your requested value.
0
 

Author Comment

by:vcharles
ID: 40403881
Hi,

Thanks for the code, how do you check to see if the file is encrypted before you attempt to decrypt it?

V.
0
 
LVL 36

Expert Comment

by:Miguel Oz
ID: 40404277
Regarding post question, the short answer is : NO.
If a code can determine this, it could mean that the encryption algorithm was broken. The goal of the encryption is to produce a file that looks like a random chunk of data.
Having said that you could add an extra node element to your xml, this element should store a value that your program reads and determine whether the file contains encrypted/decrypted info.
0
 

Author Comment

by:vcharles
ID: 40404342
Thanks
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

724 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