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
Solved

wrapping gpg in vb.net to decrypt files

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

SSL stands for “Secure Sockets Layer” and an SSL certificate is a critical component to keeping your website safe, secured, and compliant. Any ecommerce website must have an SSL certificate to ensure the safe handling of sensitive information like…
Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
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 …

808 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