EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Simple PGPBlackBox Script

Posted: 02/10/2010 19:24:32
by Pierre van der Westhuizen (Basic support level)
Joined: 02/10/2010
Posts: 2

I am trying to run the following from VBA. I used the sample code provided with the ActiveX control.

I get the following error: "Error: Keyring property is not assigned" What am I missing?

Private Function GetDefaultUserID(ByVal Key As IElPGPPublicKeyX)
Dim Result As String
If Key.GetUserIDCount > 0 Then
Result = Key.GetUserID(0).UserName
Result = "untitled"
End If
GetDefaultUserID = Result
End Function

Sub ProtectSource()
Dim Licensemanager As New ElPGPLicenseManagerX
Dim PGPUtils As New ElPGPUtilsX
Dim Encrypt As Boolean
Dim Sign As Boolean
Dim I As Integer
Dim PubKey As IElPGPPublicKeyX
Dim SecKey As IElPGPSecretKeyX
Dim ConvEncryption As Boolean
Dim TextInput As Boolean
Dim fso As New FileSystemObject

Licensemanager.SetLicenseKey ("7C19...2EC3")

Dim pgpwriter As New ElPGPWriterX
Dim EncryptingKeys As New ElPGPKeyringX

Dim GlobalKeyring As New ElPGPKeyringX
Dim Key As IElPGPPublicKeyX

GlobalKeyring.LoadFromFiles "Y:\g\Projects_Current\Healthways\Lockheed\Healthways_Pub.asc", "", True

Set Key = GlobalKeyring.GetPublicKey(0)


EncryptingKeys.AddPublicKey Key

If EncryptingKeys.GetPublicCount = 0 Then
MsgBox "No encryption keys specified"
Exit Sub
End If

pgpwriter.EncryptingKeys = EncryptingKeys
pgpwriter.EncryptionType = etPublicKey

pgpwriter.UseNewFeatures = False
pgpwriter.UseOldPackets = False
pgpwriter.Armor = True
pgpwriter.ArmorHeaders.Add "Version: EldoS PGPBlackbox (ActiveX edition)"
pgpwriter.ArmorBoundary = "PGP MESSAGE"
pgpwriter.Compress = False
pgpwriter.filename = fso.GetFileName("y:\g\temp\LMC_DD_20100210.zip")
pgpwriter.TimeStamp = Now
pgpwriter.Protection = ptNormal
pgpwriter.SymmetricKeyAlgorithm = SB_PGP_ALGORITHM_SK_CAST5

On Error GoTo HandleErr

pgpwriter.SignFile "y:\g\temp\LMC_DD_20100210.zip", "y:\g\temp\LMC_DD_20100210.zip.pgp", False

MsgBox "Operation Finished"

Exit Sub

MsgBox "Error: " & Err.Description

End Sub
Posted: 02/10/2010 20:26:51
by Pierre van der Westhuizen (Basic support level)
Joined: 02/10/2010
Posts: 2

I think I solved it myself.

As the last line I should have been using:

pgpwriter.EncryptFile "y:\g\temp\LMC_DD_20100210.zip", "y:\g\temp\LMC_DD_20100210.zip.pgp"



Topic viewed 1180 times

Number of guests: 1, registered members: 0, in total hidden: 0


Back to top

As of July 15, 2016 EldoS business operates as a division of /n software, inc. For more information, please read the announcement.

Got it!