IBaseMessage Microsoft.BizTalk.Component.Interop.IComponent.Execute(IPipelineContext pContext, IBaseMessage pInMsg)
        {
            System.Diagnostics.Trace.WriteLine(">>> PgpEncrypt.Execute ()  v.3");
            IBaseMessagePart    bodyPart = pInMsg.BodyPart;
            IBaseMessageContext context  = pInMsg.Context;
            string filename = "";

            if (bodyPart != null)
            {
                filename = context.Read("ReceivedFileName", "http://schemas.microsoft.com/BizTalk/2003/file-properties").ToString();

                if (filename.Contains("\\"))
                {
                    filename = filename.Substring(filename.LastIndexOf("\\") + 1);
                }
                if (filename.Contains("/"))
                {
                    filename = filename.Substring(filename.LastIndexOf("/") + 1);
                }

                if (!String.IsNullOrEmpty(tempDirectory))
                {
                    if (!Directory.Exists(this.tempDirectory))
                    {
                        Directory.CreateDirectory(this.tempDirectory);
                    }
                }
                filename = Path.Combine(this.tempDirectory, filename);

                string tempFile = Path.Combine(this.tempDirectory, Guid.NewGuid().ToString());

                Stream encStream = PGPWrapper.EncryptStream(bodyPart.Data, this.pubKeyFile, tempFile, this.extension, this.asciiArmorFlag, this.integrityCheckFlag);

                encStream.Seek(0, SeekOrigin.Begin);
                bodyPart.Data = encStream;
                pContext.ResourceTracker.AddResource(encStream);
                context.Write("ReceivedFileName", "http://schemas.microsoft.com/BizTalk/2003/file-properties", filename + ".pgp");
            }
            return(pInMsg);
        }
        IBaseMessage Microsoft.BizTalk.Component.Interop.IComponent.Execute(IPipelineContext pContext, IBaseMessage pInMsg)
        {
            System.Diagnostics.Trace.WriteLine(">>> PgpDecrypt.Execute () v.3");
            IBaseMessagePart    bodyPart = pInMsg.BodyPart;
            IBaseMessageContext context  = pInMsg.Context;
            string filename = "";

            if (bodyPart != null)
            {
                filename = context.Read("ReceivedFileName", "http://schemas.microsoft.com/BizTalk/2003/file-properties").ToString();

                if (filename.Contains("\\"))
                {
                    filename = filename.Substring(filename.LastIndexOf("\\") + 1);
                }
                if (filename.Contains("/"))
                {
                    filename = filename.Substring(filename.LastIndexOf("/") + 1);
                }

                if (0 < this.tempDirectory.Length)
                {
                    if (!Directory.Exists(this.tempDirectory))
                    {
                        Directory.CreateDirectory(this.tempDirectory);
                    }
                }
                filename = Path.Combine(this.tempDirectory, filename);
                string tempFile = Path.Combine(this.tempDirectory, Guid.NewGuid().ToString());

                Stream decStream = PGPWrapper.DecryptStream(bodyPart.Data, this.privateKeyFile, this.passphrase, tempFile, this.tempDirectory);

                decStream.Seek(0, SeekOrigin.Begin);
                bodyPart.Data = decStream;
                pContext.ResourceTracker.AddResource(decStream);
                context.Write("ReceivedFileName", "http://schemas.microsoft.com/BizTalk/2003/file-properties", filename.Replace(".pgp", ""));
            }
            return(pInMsg);
        }