• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1377
  • Last Modified:

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

0
coder369
Asked:
coder369
  • 3
1 Solution
 
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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now