Solved

wrapping gpg in vb.net to decrypt files

Posted on 2009-05-18
4
1,227 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 500 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

This paper addresses the security of Sennheiser DECT Contact Center and Office (CC&O) headsets. It describes the DECT security chain comprised of “Pairing”, “Per Call Authentication” and “Encryption”, which are all part of the standard DECT protocol.
Encryption for Business Encryption (https://en.wikipedia.org/wiki/Encryption) ensures the safety of our data when sending emails. In most cases, to read an encrypted email you must enter a secret key that will enable you to decrypt the email. T…
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 …

832 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