Tutorial Addendum on Data Encoding - Base64 Encoding

sportsappsios utilitiesappsios adventuregamesios
 31 December 18:00   

    



    



    

Base64 encoding Algorithm

    



    

Base64 algorithm is advised to encode any bifold data, an beck of bytes, into

    

a beck of 64-printable characters.

    



    

Base64 encoding algorithm was first presented in "RFC 1421 - Aloofness Accessory

    

for Internet Cyberbanking Mail:

    

Part I: Bulletin Encryption and Affidavit Procedures" in 1993 by John Linn.

    

It was after adapted hardly in "RFC 1521 - MIME (Multipurpose Internet Mail Extensions)

    

Part One: Mechanisms for Allegorical and

    

Describing the Architecture of Internet Bulletin Bodies" in September 1993 by N. Borenstein, et al..

    



    

The 64 printable characters acclimated by Base64:

    



    

Amount encoding Amount encoding Amount encoding Amount Encoding

    



    

 

    

0 A 17 R 34 i 51 z

    

1 B 18 S 35 j 52 0

    

2 C 19 T 36 k 53 1

    

3 D 20 U 37 l 54 2

    

4 E 21 V 38 m 55 3

    

5 F 22 W 39 n 56 4

    

6 G 23 X 40 o 57 5

    

7 H 24 Y 41 p 58 6

    

8 I 25 Z 42 q 59 7

    

9 J 26 a 43 r 60 8

    

10 K 27 b 44 s 61 9

    

11 L 28 c 45 t 62 +

    

12 M 29 d 46 u 63 /

    

13 N 30 e 47 v

    

14 O 31 f 48 w

    

15 P 32 g 49 x

    

16 Q 33 h 50 y

    



    



    

The encoding action is to:

    



        

  • Divid the ascribe bytes beck into blocks of 3 bytes.

        



  •     

  • Divid the 24 $.25 of a 3-byte block into 4 groups of 6 bits.

        



  •     

  • Map anniversary accumulation of 6 $.25 to 1 printable character, based on the 6-bit value.

        



  •     

  • If the endure 3-byte block has alone 1 byte of ascribe data, pad 2 bytes of aught (x0000).

        

    After encoding it as a accustomed block, override the endure 2 characters with 2 according signs (==),

        

    so the adaptation action knows 2 bytes of aught were padded.

        



  •     

  • If the endure 3-byte block has alone 2 bytes of ascribe data, pad 1 byte of aught (x00).

        

    After encoding it as a accustomed block, override the endure 1 appearance with 1 according signs (=),

        

    so the adaptation action knows 1 byte of aught was padded.

        



  •     

  • Carriage acknowledgment (
    ) and new band (
    ) are amid into the achievement appearance stream.

        

    They will be abandoned by the adaptation process.

        



  •     



    



    

Example 1: Ascribe data, 1 byte, "A". Encoded output, 4 characters, "QQ=="

    

 

    

Input Data A

    

Input $.25 01000001

    

Padding 01000001 00000000 00000000

    



    

Bit Groups 010000 010000 000000 000000

    

Mapping Q Q A A

    

Overriding Q Q = =

    



    



    

Example 2: Ascribe data, 2 bytes, "AB". Encoded output, 4 characters, "QUI="

    

 

    

Input Data A B

    

Input $.25 01000001 01000010

    

Padding 01000001 01000010 00000000

    



    

Bit Groups 010000 010100 001000 000000

    

Mapping Q U I A

    

Overriding Q U I =

    



    



    

Example 3: Ascribe data, 3 bytes, "ABC". Encoded output, 4 characters, "QUJD"

    

 

    

Input Data A B C

    

Input $.25 01000001 01000010 01000011

    



    

Bit Groups 010000 010100 001001 000011

    

Mapping Q U J D

    



    



    



    

W3C Implementation

    



    

One of the Java implementations of Base64 algorithm accessible on the Internet is

    

from the Jigsaw activity at w3c.org. The Base64 algorithm is implemented into 2 classes,

    

Base64Encoder and Base64Decoder in the org.w3c.tools.codec package. Actuality is how to

    

download this package, and create it accessible to your Java environment.

    



        

  • Go to http://www.w3.org/Jigsaw/, and chase the apprenticeship to download jigsaw_2.2.2.zip.

        



  •     

  • Unzip jigsaw_2.2.2.zip to localjigsaw, and add localjigsawclassesjigsaw.jar to your

        

    Java chic path.

        



  •     



    



    

 


Tags: internet, example, block, process, groups, character, characters, value, knows, normal

 encoding, input, bytes, base64, characters, value, block, jigsaw, output, groups, process, stream, algorithm, internet, encoded, example, decoding, printable, character, , input data, value encoding, base64 encoding, bit groups, groups 010000, encoded output, byte block, encoding value, encoding base64, decoding process, bit groups 010000, value encoding value, encoding value encoding, encoding base64 encoding, groups 010000 010100, decoding process knows, normal block override, data encoding base64,

Share Tutorial Addendum on Data Encoding - Base64 Encoding:
Digg it!   Google Bookmarks   Del.icio.us   Yahoo! MyWeb   Furl  Binklist   Reddit!   Stumble Upon   Technorati   Windows Live   Bookmark

Text link code :
Hyper link code:

Also see ...

Permalink
Article In : Computers & Technology  -  Encoding