You are on page 1of 37

Philippine State College of Aeronautics Fernando Air Base Campus

MATHEMATICS
in the
MODERNWORLD
‘Codes are like
people. There
different typesare and
different kinds.…

-Oscar Ingham
Course Learning Outcomes [CLO]
Module Learning Outcomes [MLO]
CLO5. Use mathematics in Topic Learning Outcomes
other areas such as finance
and business, codes
and coding schemes, MLO 1. Apply coding scheme to [TLO]
networks, voting, health and encode and decode different types
medicine, environment, arts of information for identification,
and design, and recreation. TLO 16. Use coding scheme to
privacy and security purposes. encode and decode different
MLO 2. Demonstrate honesty types of information for
and integrity when using codes identification, privacy and
for security purposes security purposes.
TLO 17. Exemplify honesty and
integrity when using codes for
security purposes.
7
CODES
A code is a system of symbols, letters, words, or
signals that are used instead of ordinary words and
numbers to send messages or store information. A code
is used to keep the message short or to keep it secret.
1 0 Pa c k Wr i g l ey ’s Juicy F r u i t G u m
- fi rst b a r- c o d e d retail p r o d u c t p u r c h a s e d in 1 9 7 4
at a g ro c e r y at O h i o, U S A .
The Label
- t h e c o d e s e w n i nto a t-shirt h a s i n fo r m a ti o n o n t h e
fabric c o m p o s i ti o n a n d c o u n t r y of m a n u fa c t u r e . T h e c o d e
is like a n Att r i b u te C o d e for t h e c lothing i te m ’s c o nte n t .
C h ec k Digits
- is a digit a d d e d to a string o f n u m b e r s for
e rro r d ete c ti o n p u r p o s e s . N o r m a l l y, t h e c h e c k
digit is c o m p u t e d f r o m t h e o t h e r digits in t h e
string. A c h e c k digit h e l p s digital s y s t e m s
d ete c t c h a n g e s w h e n d a t a is t ra n sfe r re d f r o m
t ra n s m i tt e r to re ceiver.
1. I S B N - I n t e r n a ti o n a l S t a n d a r d B o o k N u m b e r is a
c o d e u s e d t o u n i q u e l y identi f y a b o o k to get h e r.

The last digit is for error detecti on. So for 13 digits, 5 an d for 10
digits 9.
2. USPS- United States Postal Service- The identification code on
a United States Postal Service money order is an 11-digit number. The first ten
digits are the actual identification code. The 11th digit is the check digit.
The check digit is calculated using the following algorithm:

Let a1, a2, a3, a4, … , a11 be the identification number on a USPS money order,
then a11 = (a1+ a2+ a3 + a4 + a5 + a6+ a7+ a8+ a9+ a10)(mod 9)
Example: Which of the following USPS money order is valid?

1. 21349002734
Answer. 2+1+3+4+9+0+0+2+7+3 = 31 = 9x3 = 27 r.4
Since the remainder is 4 which is equal to the last digit
therefore, the USPS money order is valid.

2. 31059112852
Answer. 3+1+0+5+9+1+1+2+8+5 = 35 = 9x3 = 27 r.8
Since the remainder is 8 which is NOT equal to the last digit
therefore, the USPS money order is not valid. The valid USPS money
order is 31059112858.
3. Airline Tickets- The identification number on an airline ticket is a 15-
digit number. The first fourteen digits are the actual identification number and
the 15th digit is the check digit. The check digit is calculated rom the
identification number using the following algorithm.

Let a1, a2, a3, a4, … , a15 be a valid airline ticket identification number. Then
a15 = (a1a2a3a4a5a6a7a8a9a10a11a12a13a14)(mod 7)
Example: Which of the following airline tickets is valid?

1. 003712224944050
Answer. (00371222494405)(mod7) = 530,317,849,150 r.0
Since the remainder is 0 which is equal to the last digit therefore, the
airline ticket is valid

2. 003712224955053
Answer. (00371222495505)(mod7)= 53,031,785,072 r.1
Since the remainder is 1 which is NOT equal to the last digit
therefore, the airline ticket is NOT valid. The correct digit is
003712224955051
4. UPC: Universal Product Code

UPC’s have 12 digits: a1, a2, a3, a4, … , a12, where a12 is the
check digit. When scanned, computer computes:
3a1 + a2 + 3a3 + ... + 3a11 + a12.
If this sum ends in a 0 (zero), then the UPC is correct. If this sum ends in
something other than 0, there is an error.

Example: Check if Diet Coke Can UPC: 0 49000 04481 2 is


valid.
Answer: 3(0)+4+3(9)+0+3(0)+0+3(0)+4+3(4)+8+1(3)+2 = 60. Since the
sum ends in 0, therefore Diet Coke Can UPC is valid.
5. Coda bars-credit cards
Credit card has 16 digits.
1.Add digits in positions 1, 3, 5, 7, 9, 11, 13, 15 (all
odd positions).
2. Multiply result by 2.
3.Count the number of digits in positions 1, 3, 5,
7, 9, 11, 13, 15 (all odd positions) that EXCEED
(not equal) 4 and add to total from previous step.
4. Add digits from even positions.
5.The check digit is the number needed to bring the final tally to a number that
ends in a 0 (zero).
Example: Check if the credit card number 4024 0071 2153 7947
is valid.
Answer:
Step 1. (odd positions) 4+2+0+7+2+5+7+4=31
Step 2. 31x2=62
Step 3. There are 3 numbers more than 4 in step 1, so 62+3=65
Step 4. (even positions) 0+4+0+1+1 +3+9+7=25
Step 5. step 3 + step 4= 65 + 25 = 90
Therefore, the credit card number is valid
Example: Find the check digits in 3125 6002 9645 015x .
Answer: Let x be the 16th digit or the check digit
Step 1. (odd positions) 3+2+6+0+9+4+0+5=29
Step 2. 29x2=58
Step 3. There are 3 numbers more than 4 in step 1, so 58+3=61. Step
4. (even positions) 1+5+0+2+6+5+1+x=20 +x
Step 5. 61 + 20 + x = 81 + x
81 + x = 90, x = 90-81 = 9. Therefore, the check digit is 9
Therefore the valid digit is 3125 6002 9645 0159

Note: 90 is used since it is the nearest to make a total that ends in 0


A p p l i cati o n s o f C o d e s
Cryptology
Codes and ciphers are forms of secret
communication. A code replaces words, phrases, or
sentences with groups of letters or numbers, while a
cipher rearranges letters or uses substitutes to disguise
the message. This process is called encryption or
enciphering. The science that studies such secret
communication is called cryptology.
Cryptology
Secret writing has been employed about as long as
writing has existed. Codes have been used throughout
history whenever people wanted to keep messages
private. Cryptology has long been employed by
governments, military, businesses, and organizations to
protect their messages. Today, encryption is used to
protect storage of data and transactions between
computers.
Cryptology
Cryptography involves using techniques to obscure a
message so outsiders cannot read the message. It is
typically split into two steps: encryption, in which the
message is obscured, and decryption, in which the
original message is recovered from the obscured form.
Substitution Ciphers
One simple encryption method is called a
substitution cipher.
Substitution Cipher
A substitution cipher replaces each letter in the message with a different letter,
following some established mapping.
A simple example of a substitution cipher is called the Caesar
cipher, sometimes called a shift cipher. In this approach, each
letter is replaced with a letter some fixed number of positions later
in the alphabet. For example, if we use a shift of 3, then the
letter A would be replaced with D, the 3 letters are positions later
in the alphabet.
The entire mapping would look like: DWWD FNDW QRRQ
ATTA CKAT NOON
ATTACK AT NOON
: Original: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Maps to: D E F G H I J K L M N O P Q R S T U V W X Y Z A B C
Example:
1. Use the Alphabetic Caesar cipher with shift of 3 to encrypt the message: “WE
RIDE AT NOON”
Answer: Using the map above: ZH ULGH DW QRRQ.
Note: To obscure the message, the letters are often rearranged into equal sized blocks. The message ZH ULGH DW
QRRQ could be written in blocks of three characters as ZHU LGH DWQ RRQ.

2. Use the Alphabetic Caesar cipher with shift of 3 to decrypt the message: VSB
LQV LGH

Answer: Using the map above: SPY INS IDE = SPY INSIDE .
Security: Since there are only 25 possible shifts, we would only have to try 25 different possibilities to see which
one produces results that make sense. While that would be tedious, one person could easily do this by hand in a few
minutes. A modern computer could try all possibilities in under a second.
Numeric C a e s a r C i p h e r . In this approach, each letter is
replaced with a number from 0-25. 17146204
ROGUE
A 0 G 6 M 12 S 18 Y 24
B 1 H 7 N 13 T 19 Z 25
C 2 I 8 O 14 U 20
D 3 J 9 P 15 V 21
E 4 K 10 Q 16 W 22
F 5 L 11 R 17 X 23
Example:
1. Use the numeric Caesar cipher substitution above to encrypt the word
CRYPTOGRAPHY
Answer: Using the map above: 21724151914617015724

2. Use the numeric Caesar cipher substitution above to decrypt


“17146204”

Answer: Using the map above: ROGUE


Brute Force Attack
A brute force attack is a method for breaking encryption by trying all possible encryption keys.

Alphanumeric Caesar cipher is an example of brute force attack because it is a combination of


alphabet and numbers.
Example: Use the substitution mapping below to encrypt the message
“March 12 0300”
Original: ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
Maps to: 2BQF5WRTD8IJ6HLCOSUVK3A0X9YZN1G4ME7P
Answer: Using the mapping, the message would encrypt to 62SQT
ZN Y1YY
Security: While there were only 25 possible shift cipher keys (35 if we had included numbers), there are about
1040 possible substitution ciphers. That’s much more than a trillion trillions. It would be essentially impossible,
even with supercomputers, to try every possible combination. Having a huge number of possible encryption
keys is one important part of key security.
FREQUENCY ANALYSIS
Unfortunately, alphanumeric Caesar cipher
is still not secure, because of a technique called
frequency analysis,
discovered by Arab mathematician Al-Kindi
in the 9th century. English and other
languages have certain letters than show up
more often in writing than others. For example,
the letter E shows up the most frequently in
English. The chart to the right shows the typical
distribution of characters.
Example:
The chart to the right shows the frequency of
different characters in some encrypted text.
What can you deduce about the mapping?

Because of the high frequency of the letter S in the


encrypted text, it is very likely that the substitution
maps E to S. Since W is the second most
frequent character, it likely that T or A maps to W.
Because C, A, D, and J show
up rarely in the encrypted text, it is likely they are
mapped to from J, Q, X, and Z.
TRANSPOSITION CIPHER
An early version of a transposition cipher was a Scytale,
in which paper was wrapped around a stick and the message
was written. Once unwrapped, the message would be
unreadable until the message was wrapped around a same-sized
stick again.

One modern transposition cipher is done by writing the


message in rows, then forming the encrypted message from
the text in the columns.
Example:
Encrypt the message “Meet at First and Pine at midnight” using rows 8 characters long.

We write the message in rows of 8 characters each. Nonsense characters are added to the end to
complete the last row.

MEETATFI

RSTANDPI

NEATMIDN

IGHTPXNR

We could then encode the message by recording down the columns. The first column, reading
down, would be MRNI. All together, the encoded message would be MRNI ESEG ETAH TATT
ANMP TDIX FPDN IINR. The spaces would be removed or repositioned to hide the size of table
used, since that is the encryption key in this message.
ENIGMA
The actual Enigma machines used in WWII were
more complex. Each wheel consisted of a complex
substitution cipher, and multiple wheels were used in a
chain. The specific wheels used, order of the wheels, and
starting position of the wheels formed the encryption key.
While captured Engima devices provided the Allied
forces details on the encryption method, the keys still had
to be broken to decrypt messages.
These code breaking efforts led to the development of some of the first
electronic computers by Alan Turing at Bletchley Park in the United Kingdom.
This is generally considered the beginnings of modern computing.

In the 1970s, the U.S. government had a competition and ultimately approved
an algorithm deemed DES (Data Encryption Standard) to be used for encrypting
government data. It became the standard encryption algorithm used. This
method used a combination of multiple substitution and transposition steps,
along with other steps in which the encryption key is mixed with the
message. This method uses an encryption key with length 56 bits, meaning
there are 256 possible keys.
This number of keys make a brute force attack extremely difficult and costly,
but not impossible. In 1998, a team was able to find the decryption key for a
message in 2 days, using about $250,000 worth of hardware. However, the price
and time will go down as computer power increases.

From 1997 to 2001 the government held another competition, ultimately


adopting a new method, deemed AES (Advanced Encryption Standard). This
method uses encryption keys with 128, 192, or 256 bits, providing
up to 2256 possible keys, making brute force attacks essentially
impossible.
Other Examples of Codes
Thanks!
S e e y o u a ga i n
n ex t ti m e 

87
References

◂ AufmannR. , Lockwood J. ,etal.


P hil i ppi ne Editi on: M a t h e m a ti c s i nt h e
M o d e r n World.Rex B o o k Store,Inc.(RBSI)
◂ C O M A P Inc. For all Practi cal Purposes,
Introducti on to Contemporary
Mathemati cs. 2 nd Ed.
◂ Mo s er and Chen. A Student ’s Guider to
C o d i n g a n d I nfo r m ati o n T h e o r y.

You might also like