Regarding Encryption through vb.net code using gpg

Hardeep Singh hs2412 at gmail.com
Fri Dec 18 08:29:14 CET 2009


Hi Jagadeesh

The discussion here might be of help:
http://blog.hardeep.name/computer/20080904/auto-gpg/

Hardeep Singh



On Tue, Dec 8, 2009 at 6:52 PM, Jagadeesh Bantrotu
<Jagadeesh.Bantrotu at infotech-enterprises.com> wrote:
> Hi,
>
>
>
> I am trying to encrypt the file using vb.net code but the data is not
> encrypting and it is not giving error. But if I do from cmd prompt the file
> is encrypted.
>
> Can you tell me what mistake I did in my code? I first used gpg version
> 1.4.9 with this version the code was not executed after that I tried with
> gpg version 1.2.0 but no use. Any one can help me ASAP.
>
>
>
>   Dim vGPGExecutable As Variables
>
>         Dts.VariableDispenser.LockOneForRead("GPGExecutable",
> vGPGExecutable)
>
>         Dim gpgExecutable As String
>
>         gpgExecutable = vGPGExecutable("GPGExecutable").Value.ToString
>
>         vGPGExecutable.Unlock()
>
>
>
>         Dim vHomeDir As Variables
>
>         Dts.VariableDispenser.LockOneForRead("HomeDirectory", vHomeDir)
>
>         Dim HomeDir As String
>
>         HomeDir = vHomeDir("HomeDirectory").Value.ToString
>
>         vHomeDir.Unlock()
>
>
>
>         Dim vPassPhrase As Variables
>
>         Dts.VariableDispenser.LockOneForRead("recipient", vPassPhrase)
>
>         Dim recipient As String = vPassPhrase("recipient").Value.ToString
>
>         vPassPhrase.Unlock()
>
>
>
>         Dim outputFile As String =
> Dts.Connections("Encrypt").ConnectionString
>
>         Dim inputfile As String = Dts.Connections("File").ConnectionString
>
>
>
>
>
>         If System.IO.File.Exists(inputfile) = True Then
>
>
>
>             Dim gpgOptions As String
>
>
>
>             Dim optionsBuilder As StringBuilder = New StringBuilder()
>
>             optionsBuilder.Append("--homedir ")
>
>             optionsBuilder.Append(HomeDir)
>
>             optionsBuilder.Append(" --yes --batch --armor --recipient ")
>
>             optionsBuilder.Append(recipient)
>
>             optionsBuilder.Append(" --no-verbose --output ")
>
>             optionsBuilder.Append(outputFile)
>
>             optionsBuilder.Append(" --always-trust")
>
>             optionsBuilder.Append(" --encrypt ")
>
>             optionsBuilder.Append(inputfile)
>
>
>
>             gpgOptions = optionsBuilder.ToString()
>
>
>
>             Dim process As Process = New Process()
>
>             Dim streamWriter As StreamWriter
>
>             Dim streamReader As StreamReader
>
>             Dim err As StreamReader
>
>
>
>             Dim prStartInfo As ProcessStartInfo = New
> ProcessStartInfo(gpgExecutable, gpgOptions)
>
>             prStartInfo.UseShellExecute = False
>
>             prStartInfo.RedirectStandardInput = True
>
>             prStartInfo.RedirectStandardOutput = True
>
>             prStartInfo.RedirectStandardError = True
>
>             prStartInfo.CreateNoWindow = True
>
>             process.StartInfo = prStartInfo
>
>             process.Start()
>
>             streamWriter = process.StandardInput
>
>             streamReader = process.StandardOutput
>
>             err = process.StandardError
>
>             streamWriter.Close()
>
>
>
>         Else
>
>             Dim logConstr As String
>
>             logConstr = Dts.Connections("Log File Connection
> String").ConnectionString
>
>             Dim logfile As StreamWriter = New StreamWriter(logConstr, False)
>
>             logfile.WriteLine("Fail to Find Records File to be Encrypted.")
>
>             Dts.TaskResult = Dts.Results.Failure
>
>
>
>             logfile.Close()
>
>         End If
>
>
>
> Thanks&Regards,
>
> Jagadeesh B
>
> ________________________________
> DISCLAIMER:
>
> This email may contain confidential information and is intended only for the
> use of the specific individual(s) to which it is addressed. If you are not
> the intended recipient of this email, you are hereby notified that any
> unauthorized use, dissemination or copying of this email or the information
> contained in it or attached to it is strictly prohibited. If you received
> this message in error, please immediately notify the sender at Infotech or
> Mail.Admin at infotech-enterprises.com and delete the original message.
>
> _______________________________________________
> Gnupg-users mailing list
> Gnupg-users at gnupg.org
> http://lists.gnupg.org/mailman/listinfo/gnupg-users
>
>



More information about the Gnupg-users mailing list