Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

wrapping gpg in vb.net to decrypt files

Posted on 2009-05-18
4
Medium Priority
?
1,318 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
[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
  • 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

Put Machine Learning to Work--Protect Your Clients

Machine learning means Smarter Cybersecurity™ Solutions.
As technology continues to advance, managing and analyzing massive data sets just can’t be accomplished by humans alone. It requires huge amounts of memory and storage, as well as high-speed processing of the cloud.

Question has a verified solution.

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

There are many Password Managers (PM) out there to choose from. PM's can help with your password habits and routines, but they should not be a crutch you rely on too heavily. I also have an article for company/enterprise PM's.
Will you be ready when the clock on GDPR compliance runs out? Is GDPR even something you need to worry about? Find out more about the upcoming regulation changes and download our comprehensive GDPR checklist today !
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…
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…
Suggested Courses

721 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