Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

wrapping gpg in vb.net to decrypt files

Posted on 2009-05-18
4
Medium Priority
?
1,338 Views
Last Modified: 2012-05-07
I am receiving files encrypted using gpg. I have set Gnupg for Windows to work with a passphrase. How can I use vb.net 2008 to decrypt a whole folder of files? Anyone have a sample? Thanks.
0
Comment
Question by:jwagman
  • 3
4 Comments
 
LVL 9

Expert Comment

by:cdaly33
ID: 24416517
I use this in several apps every day.  I run it as a process inside vb.net.  For your scenario just loop through each file and run my code below.
      '*** decrypt - start
      Dim executestring As String = String.Format("""{0}"" --decrypt-files ""{1}""", gpgpath, tempsourcepath)
      Dim psi As New  _
        System.Diagnostics.ProcessStartInfo(executestring)
      psi.RedirectStandardOutput = True
      psi.WindowStyle = ProcessWindowStyle.Hidden
      psi.UseShellExecute = False
 
      Dim decrypt As System.Diagnostics.Process
      decrypt = System.Diagnostics.Process.Start(psi)
      Dim myOutput As System.IO.StreamReader = decrypt.StandardOutput
      decrypt.WaitForExit(20000)
      If decrypt.HasExited Then
        Dim output As String = myOutput.ReadToEnd
        Debug.WriteLine(output)
      End If
      '*** decrypt - end

Open in new window

0
 
LVL 9

Expert Comment

by:cdaly33
ID: 24416527
Alternatively here is a .net wrapper for gpg.
http://aspalliance.com/748
0
 

Author Comment

by:jwagman
ID: 24416547
Don't I need to include the passphrase as one of the args to process?
0
 
LVL 9

Accepted Solution

by:
cdaly33 earned 1500 total points
ID: 24416611
Yes, the gpg documentation has the parameter for passing the passphrase.  I'm not sure off the top of head what arg name it uses.

For you:
      Dim executestring As String = String.Format("""{0}"" --decrypt-files ""{1}""", gpgpath, tempsourcepath)

Becomes:
      Dim executestring As String = String.Format("""{0}"" --decrypt-files ""{1}"" --argnameforpassphrase passphrase", gpgpath, tempsourcepath)

0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This article covers the basics of data encryption, what it is, how it works, and why it's important. If you've ever wondered what goes on when you "encrypt" data, you can look here to build a good foundation for your personal learning.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Suggested Courses

877 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