Home
4Art
    Favorite Artists
    Personal Art
    Tutorials
4Education
    Astronomy
    Cryogenic Fluids
    Logic & Circuits
4Personal
    Dallas Photographs
    Cancun Photographs
    Hawaii Photographs
4Professional
    Business Skill
    Employment History
    Programming
    Web Administration
4Recreation
    Television
    Gaming - RPG
4Administration
    Navigation
    Sites
    Users
    Groups
 
 

Webmaster Tools


Base64 and Ascii Conversions

Description

Base64
0000000000111111111122222222223333333333444444444455555555556666
0123456789012345678901234567890123456789012345678901234567890123
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/

Hexadecimal !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abc 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000111111111122222222223333333333444444444455555555556666666666777777777788888888889999999999 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 defghijklmnopqrstuvwxyz{|}~ 1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 0000000000111111111122222222223333333333444444444455555555556666666666777777777788888888889999999999 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 22222222222222222222222222222222222222222222222222222222 00000000001111111111222222222233333333334444444444555555 01234567890123456789012345678901234567890123456789012345

Example: "Hello"

Take 3 characters in hexadecimal (normal ascii) and break them into their 8 bits:

"Hel" -> 72.101.108 -> 01001000.01100101.01101100

break these 24 bits into 4 groups of 6, convert those to numbers, and then match them to the base64 chart above:

010010.000110.010101.101100 -> 18.6.21.44 -> "SGVs"

Take the next 3 characters in hexadecimal and repeat:

"lo" -> 108.111.x -> 01101100.01101111.xxxxxxxx
011011.000110.1111xx.xxxx -> 27.6.60.x -> "bG8="

Notice that we have fewer than 3 characters left. We just substitute "x"s. when the "x"s are part of a number, we translate these to zero, and any "number" that is all x's we interpret as an equal sign (=). If the original ascii had a number of characters that was a multiple of 3, there is no equal sign. One equal sign indicates that the original ascii was one character shy of being a multiple of 3. Two equal signs indicates that the original ascii was two characters short of being a multiple of 3.

the final translation is "Hello" -> "SGVsbG8="

Javascript:

Unencoded:
Encoded:


 
 
 
 
Email comments to: Joshua Jacobsen
Last modified: 1/29/2005 11:38:15 PM
Make This Page Your HomepageMake This Page a FavoritePrint This Page
URL for this page: http://www.drowlord.com/Professional/Programming/Base64EncodeDecode.html
Copyright© 1999 - 2005 Joshua Jacobsen