Presentation is loading. Please wait.

Presentation is loading. Please wait.

Student: Ying Hong Course: Database Security Instructor: Dr. Yang

Similar presentations


Presentation on theme: "Student: Ying Hong Course: Database Security Instructor: Dr. Yang"— Presentation transcript:

1 Student: Ying Hong Course: Database Security Instructor: Dr. Yang
Base64 Encode and Decode Student: Ying Hong Course: Database Security Instructor: Dr. Yang 12/5/2018 Base64 Encode & Decode

2 Contents Introduction Algorithm Example Issues for Considerations
Other Methods References 12/5/2018 Base64 Encode & Decode

3 Introduction The Base64 Content-Transfer-Encoding is a method to encode an arbitrary sequence of octets in a form that is unintelligible to unauthorized readers. It’s used for MIME (Multipurpose Internet Mail Extensions) and various other Internet-related applications. 12/5/2018 Base64 Encode & Decode

4 Algorithm Read inputs from left to right.
Combine 3 8-bit input data to a 24-bit input group. Split each 24-bit input group to 4 6-bit units. If last group is not 24-bit, add zero bits to form 4 6-bit units. Translate each 6-bit input data into a single digit. The digit is used as an index into the base64 alphabet table. 12/5/2018 Base64 Encode & Decode

5 Algorithm con’t Represent each digit by its corresponding alphabet in the base64 alphabet table. Set the last several output characters (at most two) that do not represent actual input data to the character “=“. That is, in the last group last one or two 6-bit units may be “0”; you should either interpret it/them to “A” if they come from the plaintext, or set it/them to “=“ if they are added by ourselves. 12/5/2018 Base64 Encode & Decode

6 The Base64 Alphabet Table
12/5/2018 Base64 Encode & Decode

7 Example To encode “www.cl.uh.edu”:
Represent “ as its ASCII code number (in hexadecimal for easier to be represented as binary number later): E 63 6C 2E E Represent it as binary number and combine 3 8-bit input data to a 24-bit group: , , … … 12/5/2018 Base64 Encode & Decode

8 Example con’t Form 4 6-bit inputs in each 24-bit group:
, , … … Attention: in the last group is only (7510), so we need to add 0’s to form 4 6-bit units, that is, NOTE: last 2 6-bit units don’t represent actual input data Translate each 6-bit input into a single digit: , , , , 12/5/2018 Base64 Encode & Decode

9 Example con’t Each digit is used as index into the base64 alphabet table. Represent each digit as corresponding character in the base64 table: , , , , d d 3 , L m N s , L n V o , L m V T , d Q = = Attention: Last two 0’s are interpreted as “=“, because they do NOT represent actual input data, they are added by ourselves. The final result of encoding “ is: “d3d3LmNsLnVoLmVTdQ==”. 12/5/2018 Base64 Encode & Decode

10 Issues for Considerations
The encoded data are consistently about 33% larger than the unencoded data. The output stream (encoded bytes) must be represented in lines of no more than 76 characters each. 12/5/2018 Base64 Encode & Decode

11 Issues for Considerations con’t
All other characters (including line breaks) not found in the table must be ignored during decoding, since they probably indicate a transmission error, for which a warning message or a rejection message may be given under some circumstances. 12/5/2018 Base64 Encode & Decode

12 Issues for Considerations con’t
Careful decoding must be made when last group of input data is less than 24 bits, that is adding 0’s bits to form multiple of 6-bit unit and set output character that doesn’t represent actual input data to the character “=“. Three cases may occur in the last group of output: inputs are 24 bits, outputs are 4 characters with no “=“ inputs are 16 bits, outputs are 3 characters with one “=“ inputs are 8 bits, outputs are 2 characters with two “=“ 12/5/2018 Base64 Encode & Decode

13 Issues for Considerations con’t
Care must be taken when directly encoding text material. That is, some special characters like line breaks should be converted into CRLF sequences prior to base64 encoding (that means you should be aware of both printable characters and those control code). 12/5/2018 Base64 Encode & Decode

14 Other Methods  uuencode
Uuencode is a set of algorithms that convert files to 7-bit ASCII characters, which can be transmitted over the Internet. It’s especially popular for sending attachments. Originally, uuencode stood for Unix-to-Unix encode, but it has become a universal protocol to transfer files between different platforms such as Unix, Windows, and Macintosh. 12/5/2018 Base64 Encode & Decode

15 Other Methods  Base85 The Base85 encoding is used to encode IPv6 address, which is treated as a 128-bit integer. The Base85 digits in ascending order are: 0..9, A..Z, a..z, !, #, $, %, &, (, ), *, +,-, ;, <, =, >, ^, _, `, {, |, }, ~. 12/5/2018 Base64 Encode & Decode

16 Other Methods  Base85 con’t
Algorithm: Convert address to decimal number. 1080:0:0:0:8:800:200C:417A (Hex.) (Dec.) Divide this number by 85 and take the remainder, then continue to divide the quotient by 85 and take the remainder, and so on. The remainders are: 51, 34, 65, 57, 58, 0, 75, 53, 37,4, 19, 61, 31, 63, 12, 66, 46, 70, 68, 4. Reverse the order of the remainders. 4, 68, 70, 46, 66, 12, 63, 31, 61, 19, 4, 37, 53, 75, 0, 58, 57, 65, 34, 51. 12/5/2018 Base64 Encode & Decode

17 Other Methods  Base85 con’t
Algorithm (con’t): Use the numbers (reversed remainders) as index into the Base85 alphabet table to get the corresponding characters. 4, 68, 70, 46, 66, 12, 63, 31, 61, 19, (remainders) 4, ), +, k, &, C, #, V, z, J, (encoded in Base85) 4, 37, 53, 75, 0, 58, 57, 65, 34, (remainders) 4, b, r, >, 0, w, v, %, Y, p (encoded in Base85) Final result is: 4)+k&C#VzJ4br>0wv%Yp 12/5/2018 Base64 Encode & Decode

18 Other Methods  Base85 con’t
Benefits: Reduce IPv6 address length when encoding it in textual format, that is from 39 characters to 20 characters. Encode IPv6 address to a fixed-length representation. It’s very hard to be decoded by any casual observer, so it’s more secure. Other issues: So far many current processors don’t have 128-bit arithmetic. Future processors should address this defect before any significant IPv6 deployment has been accomplished. 12/5/2018 Base64 Encode & Decode

19 References (Base64) RFC 1521 (Base64) (uuencode) RFC 1924 (Base85) 12/5/2018 Base64 Encode & Decode


Download ppt "Student: Ying Hong Course: Database Security Instructor: Dr. Yang"

Similar presentations


Ads by Google