Regarding Encryption through vb.net code using gpg

Jagadeesh Bantrotu Jagadeesh.Bantrotu at infotech-enterprises.com
Tue Dec 8 14:22:54 CET 2009


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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/attachments/20091208/4f20e990/attachment-0001.htm>


More information about the Gnupg-users mailing list