You are on page 1of 9

Base64 Encoding

Jonathan Francis Roscoe


jjr6@aber.ac.uk

Topics of Discussion

Encoding and encryption What is base64 used for? Usage of base64 encoding The algorithm Drawbacks lternati!es

Encoding and Encryption

"eople often refer to base64 #and similar methods$ as a form of encryption% Encoding is the process of transforming information from one format into another%

Transfer &torage 'ormating #eg% (aTe) * semantics encoding$

Encryption is a type of encoding that obscures information to make it unreadable without special knowledge%

"ositional notation * a +uadrose,agesimal number system -umerals ./01 alphabetical characters a/2 and plus two special characters #all printable &455$ /3

What is base64?

VGhlIHF1aWNrIGJyb3duIGZveCByYW4 b3Zlc!B"aG# bGF6e$ Bkb%c&


Value Base64 Value Base64 Value Base64 Value Base64 0 A 16 ! 32 . 48 ; 1 B 17 " 33 / 49 < 2 C 18 # 34 0 50 = 3 D 19 $ 35 1 51 > 4 E 20 % 36 2 52 0 5 F 21 V 37 l 53 1 6 G 22 & 38 3 54 2 7 H 23 ' 39 4 55 3 8 I 24 ( 40 5 56 4 9 J 25 ) 41 6 57 5 10 K 26 a 42 7 58 6 11 L 27 * 43 8 59 7 12 M 28 + 44 s 60 8 13 N 29 , 45 9 61 9 14 O 30 e 46 u 62 ? 15

31 47 : 63 @

What is base64 used for?

6Binary to te,t7 encoding% "rimarily used in &8T" / transfer protocol allows only 9/bit &455 characters to be used% Base64 will encode any bit stream as a se+uence of 9/bit &455 characters #ie% Binary data to plainte,t$% 8ultipurpose 5nternet 8ail E,tensions UT'/9 nti/spam e!asion Binary data embedded in )8(

The Encoding

lgorithm

Binary data is split into groups of :4 bits #; bytes$1 then split into 6/bit chunks and con!erted to the corresponding &455 characters%
Original bit stream 6-bit chunks "11"1"11"11"1"1""11"1"11 "11"1"'11"11"'1"1""1'1"1"11

Decimal

%6'(4'41'43

Base64

a%)r

The Encoding

lgorithm

What if we don<t ha!e a multiple of ; bytes in our bit stream?


Original bit stream "11"""1""11"11"""111"1"1"11""1"1

Take first 24 bits, split into 6-bits Decimal

"11"""'1""11"'11"""1'11"1"1

%4'3*'4+'(3

Base64

Y,-1

The Encoding
Take remaining bits "11""1"1 Take first 24 bits, split into 6-bits ill incomplete bits with !eros Decimal

lgorithm

"11""1'"1----'------'------

"11""1'"1""""'------'------

%('%6

Base64, replace blank bits with '='

Z.&&

=ther -otes

;;> increase in si2e &455?@1 Auoted/printable1 ?B5T858E "ri!acy/Enhanced Electronic 8ail was the first place where base64 was used Beaders usually describe if a message is encoded in base641 it is up to the client to translate

You might also like