Encrypt Files using PGP in DTS

Hey guys,

Here's my dilemma. I have a DTS package that gets a list of reports that need to run. It will then iterate through that list via active-X script, and create excel reports. The package then automatically posts them to there individual FTP locations. However, Some of these FTP's are not secure and these clients, as we are dealing with PHI (private health info), have requested that the reports be encrypted via PGP. This is all fine a well except, I can't seem to automate PGP encryption. I am using PGP 9.7.

I know there is a COM object "NSDPGP3Lib" but that only seems to work while being used in VB6 or .NET. I can't get it working in VBS.

Here's what I have for code. Obviously, it's not working yet.
Private Function EncryptFile(FilePath, RcptKeyId)
    Set fsObj = CreateObject("Scripting.FileSystemObject")
    Set PGP = CreateObject("NSDPGP3Lib.PGP")
    Set File = fsObj.GetFile(FilePath)
    
    Public_Ring = "c:\Test.pkr"
    Privite_Ring = "c:\Test.skr"
 
    OutputFilePath = Replace(File.Name, ".xls", "")   
  
    Call PGP.EncryptFile(Public_Ring, Privite_Ring, FilePath, OutputFilePath, BINARY_FILE, BINARY_FILE, RcptKeyId)
    
    Set PGP = Nothing
    Set fsObj = Nothing
End Function

Open in new window

coder369Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

James MurrellProduct SpecialistCommented:
0
coder369Author Commented:
Yes I've read that article a few times now. It might work but I would need more details as to how to set it up with PGP.
0
Anthony PerkinsCommented:
>>I know there is a COM object "NSDPGP3Lib" but that only seems to work while being used in VB6 or .NET. I can't get it working in VBS.<<
Assuming that DTS is (and will) execute on the same box that has the COM object, can you tell us what error message if any you are getting?  If you do not get an error message than what exactly is the problem?

Also, can you post your VB6 code?

And finally, you do realize that you are building OutputFilePath without a full path, right? All it has is a file name without an extension, so perhaps it has succeeded, it is just that it has left the file in a totally different place (perhaps in Microsoft SQL Server\80\Tools\Binn).
0
coder369Author Commented:
I'm decrypting in vb6 so it's slightly different. I'm a .NET guy so bare with the code if you can. (it was handed down to me)

Here's a question. Is the PGP COM object registered upon installation? or does it have to be done manually?

Finally, i did notice that i'm not specifying an output path... right after you told me.  =P  thanks! but as you'll see in the error message below this is not the error.

Set fso = New FileSystemObject
Set fld = fso.GetFolder(SourceDir)
Set pgp = CreateObject("NSDPGP3Lib.PGP")
 
Call pgp.DecryptFile(pubringloc, privringloc, SourceFile, OutputFile, passphrase)
 
Set pgp = Nothing
Set fso = Nothing

Open in new window

DtsErr.jpg
0
coder369Author Commented:
THIS WORKS! just had to register a nsdpgp3.dll

Regsvr32 C:\dll\nsdpgp3.dll

Now it works beautifully!
Private Function EncryptFile(FilePath, RcptKeyId)
    Set fsObj = CreateObject("Scripting.FileSystemObject")
    Set PGP = CreateObject("NSDPGP3Lib.PGP")
    Set File = fsObj.GetFile(FilePath)
    
    Public_Ring = "pkr location"
    Privite_Ring = "skr location"
 
    OutputFilePath = Replace(File.Path, ".xls", ".pgp")   
  
    Call PGP.EncryptFile(Public_Ring, Privite_Ring, FilePath, OutputFilePath, BINARY_FILE, BINARY_FILE, RcptKeyId)
    
    Set PGP = Nothing
    Set fsObj = Nothing
    
End Function

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.