Chapter 7 Data Coding Agenda • • • • Coding Code efficiency and conversion Compression/compaction Code encryption/decryption Coding • Definition – A predetermined set of symbols having specific meanings • Types – Human code • Morse code (dot and dash for telegraph) – Machine code • Binary states • Binary digit (bit) Machine Codes - I • Characteristics – – – – Two-state code Same number of bits Perfectly formed Same transmission duration • Character Assignment: unique sequence of bits Machine Codes - II • Types of characters – Alphanumeric – Format effector for terminal screen or paper – Control (device & transmission) Parity checking • Parity bit • Even or odd Escape mechanisms • Escape or ESC Character • Pro: – Increase codes • Con: – Code and decode the data Specific Codes • Baudot code • American Standard Code for Information Interchange (ASCII) • Extended Binary Coded Decimal Interchange Code (EBCDIC) • Unicode • Binary Coded Decimal • N-out-of-M code Baudot Code • 5 bits (32 code points) • ESC mechanism – Figure shift (uppercase) – Letter shift (lowercase) • Teletypewriters before 1965 • No error checking American Standard Code for Information Interchange (ASCII) • By American National Standards Institute (ANSI) • 7654321 (7-bit or 128 characters) • Pros: – Easy sorting by computers – Used by microcomputers Extended binary Coded Decimal Interchange Code (EBCDIC) • 8-bit code or 256 characters • IBM mainframe computers • 01234567 Unicode • 16-bit or 65,536 characters • By Unicode Consortium for international languages • Used by Windows NT Other Codes • Binary Coded Decimal – 6-bit code Hollerith code – No standard • N-Out-Of-M Codes – M bits to transmit each character, n must be 1s – Error Detection – IBM’s 4-out-of-8 Control Characters • Transmission control characters – SOH, STX, ETX, EOT, ACK, NAK, NUL • Device control characters – BEL, DC1 (X-ON), DC3 (X-OFF) • Format effect control characters – CR, LF, HT, VT Code Efficiency • Types of bits in a character – Information bits – Noninformation bits (parity bit) • Definition: No. of information bits divided by the total no. of bits in a character Code Conversion • Harder from larger no. of bits code to smaller no. of bits code • Use ESC mechanism Data Compression/Compaction • Types – Character compression/Huffman coding or adaptive Huffman coding (bits assignment) – Run length coding (repetitive characters) – Character stripping (heading & trailing characters) – Combination of the above three • Consideration – throughput – Storage and transmission cost – Hardware cost & software cost Code Encryption • Voice – Scramble and descramble • Data – Symmetric key • Data encryption standard (DES) by National Institute of Standard and Technology (2 to 56) • Triple DES (2 to 112) • Key security – Asymmetric key or RSA encryption – Public key & private key • Consideration – Hardware and/or software cost – Time delay – Security management cost Example of Encryption - I • Divide text into groups of 8 characters. Pad with blank at end as necessary • Select an 8-characters key • Rearrange text by interchanging adjacent characters • Translate each character into an ordinal number with blank as 0, A as 1, B as 2… • Add the ordinal number of the key to the results • Divide the total by 27 and retain the remainder • Translate the remainder back into a character to yield the cipher text Example of Encryption - II • • • • • • • • • Message: DATA COM Key: PROTOCOL A D A T C M O 01 04 01 20 03 00 13 15 01 04 01 20 03 00 13 15 16 18 15 20 15 03 15 12 17 22 16 40 18 03 28 27 17 22 16 13 18 03 01 00 Q V P M R C A SPACE Example of Decryption - I • Divide cipher text into groups of eight characters. Pad with blanks at end as necessary • Translate each cipher text alphabetic character and the encryption key into an ordinal number • For each group, subtract the ordinal number of the key value from the ordinal number of the cipher text • Add 27 to any negative number • Translate the number back to alphabetic equivalents • Rearrange the text by interchanging adjacent characters Example of Decryption - II • • • • • • • • • Q V P M R C A SPACE 17 22 16 13 18 03 01 00 17 22 16 13 18 03 01 00 16 18 15 20 15 03 15 12 01 04 01 -7 01 00 -14 -12 plus 27 27 27 27 01 04 01 20 01 00 13 15 A D A T C M O D A T A C O M Points to Remember • • • • Coding Code efficiency and conversion Compression/compaction Code encryption/decryption Discussion • Design the efficient and secure coding system for an international company Assignment • Review chapters 1-7 • Read chapters 8-9