Avoiding + sign in encyption

I have the code below which encrypts strings for me. The issue I just ran into is it created a string as follows, "I+kP8WgPP1K5LiaLyxSOyA==" is there any way I can stop it from using non-alphanumeric codes? e.g. the addition sign. This is causing me issues when I try to use that string in a URL

Private Function Encrypt(clearText As String) As String
        Dim EncryptionKey As String = "encryptionkey"
        Dim clearBytes As Byte() = Encoding.Unicode.GetBytes(clearText)
        Using encryptor As Aes = Aes.Create()
            Dim pdb As New Rfc2898DeriveBytes(EncryptionKey, New Byte() {&H49, &H76, &H61, &H6E, &H20, &H4D,
             &H65, &H64, &H76, &H65, &H64, &H65,
            encryptor.Key = pdb.GetBytes(32)
            encryptor.IV = pdb.GetBytes(16)
            Using ms As New MemoryStream()
                Using cs As New CryptoStream(ms, encryptor.CreateEncryptor(), CryptoStreamMode.Write)
                    cs.Write(clearBytes, 0, clearBytes.Length)
                End Using
                clearText = Convert.ToBase64String(ms.ToArray())
            End Using
        End Using
        Return clearText
    End Function

Open in new window

David CIT Projects ManagerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Éric MoreauSenior .Net ConsultantCommented:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
David CIT Projects ManagerAuthor Commented:
Hi Éric, I am already using UrlEncode but I forgot to mention that I am using the querystring in the URL to populate an image control. The image control shows a broken image.

I tested the image control with a sample image called '1+1.png' and that doesn't work either even with '%2b'.
Éric MoreauSenior .Net ConsultantCommented:
how big is your encoded string? a URL has a limited capacity somewhere between 250 and 2000 depending on the browser and its version
David CIT Projects ManagerAuthor Commented:
It's I%2bkP8WgPP1K5LiaLyxSOyA== the issue is I can't have an image with that name and if the image is called I+kP8WgPP1K5LiaLyxSOyA== it fails to load
David CIT Projects ManagerAuthor Commented:
Ended up not encrypting it but URL Encode could help someone
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.