vikasbapat
asked on
How to Encode URL in Base64 in C# windows application?
Hi,
I want to encode an URL in to Base64 in c# windows application.
Please help me.
I want to encode an URL in to Base64 in c# windows application.
Please help me.
Get the URL string as byte[] and then do Convert.ToBase64String(byt e[]);
ASKER
Thanks for reply.
But How to get URL in Byte[].
I m having following url which is to be encoded Base64
"http://stg1.experian.com/lookupServlet1?lookupServiceName=AccessPoint&lookupServiceVersion=1.0&serviceName=NetConnectDemo&serviceVersion=2.0&responseType=text/plain"
But How to get URL in Byte[].
I m having following url which is to be encoded Base64
"http://stg1.experian.com/lookupServlet1?lookupServiceName=AccessPoint&lookupServiceVersion=1.0&serviceName=NetConnectDemo&serviceVersion=2.0&responseType=text/plain"
This ought to work:
using System.Text;
byte[] urlBytes = Encoding.ASCII.GetBytes(ur l);
string urlB64 = Convert.ToBase64String(url Bytes);
If you want the URL treated as, for example, Unicode, you would change the encoding like so:
byte[] urlBytes = Encoding.Unicode.GetBytes( url);
using System.Text;
byte[] urlBytes = Encoding.ASCII.GetBytes(ur
string urlB64 = Convert.ToBase64String(url
If you want the URL treated as, for example, Unicode, you would change the encoding like so:
byte[] urlBytes = Encoding.Unicode.GetBytes(
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It is working fine.
Thanks for quick responce.
Thanks for quick responce.
Thanks, I tell you how to encode to base64 and you award points for converting a string to bytes.
You could have at least split the points there.
You could have at least split the points there.
Yes, agreed. And a B?
(BTW ozymandias, hadn't intended to steal this one, just saw it in passing. Assumed you'd already basically won the points ...)
Don't worry about it, these things happen.
I nearly came back and added the bit about converting a string to bytes but thought that was kinda overkill.
I nearly came back and added the bit about converting a string to bytes but thought that was kinda overkill.
:)