narayanpatra
narayanpatra

Reputation: 5691

How to encode in base 64 and hex?

I read following two lines in the book : The Web Application Hacker’s Hand- book.

For example, the Base64-encoded form of The Web Application Hacker’s Hand- book is: VGhlIFdlYiBBcHBsaWNhdGlvbiBIYWNrZXIncyBIYW5kYm9vaw==

For example, hex-encoding the username “daf” within a cookie would result in: 646166

Can anybody explain me how this conversion is done?

Upvotes: 0

Views: 831

Answers (1)

Sitnik
Sitnik

Reputation: 610

You can read more about Base64 in the Wikipedia article.

Doing the actual conversion to Base64 will depend on what programming language you are using. For instance, in the System.Text namespace of the .NET Framework you will find a method called Convert.ToBase64String that will do it for you.

For the hex encoding, all you need to do is get the corresponding hexadecimal value of each character. Take a look at this ASCII Table, in the Hx column you will see that d is 64, a is 61 and f is 66.

Again, the actual conversion will depend on the language you're using.

Upvotes: 1

Related Questions