> Public Function Encrypt(ByVal data As String, ByVal userKey As String, _ > ByVal alg As EncryptionAlgorithm) As Boolean > Dim cipherText As Byte() > > ' Create the encryptor object, specifying 3DES as the encryption algorithm > Dim enc As New Encryptor(alg) > > ' Get the connection string as a byte array > Dim plainText As Byte() = Encoding.ASCII.GetBytes(data) > Dim key As Byte() = Encoding.ASCII.GetBytes(userKey) > > ' Perform the encryption > If Not enc.Encrypt(plainText, key) Then > > ' Get the proper definition as per the current scope > If oProcess Is Nothing Then > oApp.ErrorSetupControlledByTheFramework("Unable to encrypt. " + _ > "The message is: " + enc.cError) > Else > oProcess.ErrorSetupControlledByTheFramework("Unable to encrypt. " + _ > "The message is: " + enc.cError) > End If > > Return False > End If > > cipherText = enc.oMemoryStreamEncryptedData > > ' Store the intialization vector, as this will be required for decryption > Dim initVector As [String] = Convert.ToBase64String(enc.IV) > > cEncrypt = initVector + " " + Convert.ToBase64String(cipherText) > Return True > End Function >>