I want to encrypt my data before I encode. Is it possible to do this all in one step using both the Xceed Binary Encoding Library and the Xceed Encryption Library? User (Old forums)
It is possible to encrypt the data before encoding it using the SubProcessing property of the Xceed Binary Encoding Library. In order to do this, you will need to do the following:
1- Declare and instance of the Xceed Binary Encoding Library, the Base64 EncodingFormat as well as the RSA EncryptionMethod (to encrypt the data).
Dim xEncode As New XceedBinaryEncoding Dim xRsa As New XceedRSAEncryptionMethod Dim xBase64 As New XceedBase64EncodingFormat
2- Set the public and private key pair(s) you want to use. You can either generate them automatically using the SetRandomKeyPair of the RSAEncryptionMethod, or you can set the PublicKey and PrivateKey properties manually. Keep in mind that keys MUST be of the OAEP standard.
Call xRsa.SetRandomKeyPair(512, Empty)
‘Dim vaPublicKey As Variant ‘xRsa.PublicKey = vaPublicKey
3- Next, set the some properties of the Base64 object and assign the EncryptionMethod to it’s SubProcessing property. Once this is done, assign the Base64 EncodingFormat to the EncodingFormat property of the Xceed Binary Encoding Library.
xBase64.EndOfLineType = bltNone Set xBase64.SubProcessing = xRsa Set xEncode.EncodingFormat = xBase64
4- You are now ready to encode and decode your data!
Dim vaSource As Variant vaSource = “This is a test”
Dim vaDestination As Variant vaDestination = xEncode.Encode(vaSource, True) Debug.Print StrConv(vaDestination, vbUnicode) Debug.Print xEncode.Decode(vaDestination, True)
5- Don’t forget to release your instances once you are finished;
Set xRsa = Nothing Set xBase64 = Nothing Set xEncode = Nothing
Imported from legacy forums. Posted by Xceed admin (had 1569 views)