views:

204

answers:

1

I need to validate a basic authorization header that is being sent to my HttpListener in VB.NET. I'm grabbing the header like so (feel free to point out better ways to do this as well):

EncodedAuth = Context.Request.Headers.GetValues("Authorization")(1)

Now how do I decode them? I understand the theory but I can't seem to find the right code.

Thank you.

+4  A: 

This should do it...

basicData = System.Text.ASCIIEncoding.ASCII.GetString( System.Convert.FromBase64String( EncodedAuth ) )

This will give you a string in the format "username:password". Split the string on ":" and you'll get the credentials.

David
Just what I was looking for, thanks.
Ryan