Link to home
Start Free TrialLog in
Avatar of coder369
coder369Flag for United States of America

asked on

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

Avatar of James Murrell
James Murrell
Flag of United Kingdom of Great Britain and Northern Ireland image

Avatar of coder369

ASKER

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.
>>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).
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
ASKER CERTIFIED SOLUTION
Avatar of coder369
coder369
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial