0% found this document useful (0 votes)
8 views

coding-and-cryptography

Uploaded by

ramiscaljessa005
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

coding-and-cryptography

Uploaded by

ramiscaljessa005
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

CODING THEORY AND CRYTPOGRAPHY

Coding is always associated with data compression, cryptology, error-correcting


and/or error detecting codes. As stated by www2.kenyu.edu, “the term ‘Coding
Theory’ has become associated predominantly with error-correcting codes.”
However, it is more than just mathematics; it almost covers all fields of study
particularly, computer sciences and information technology.

I. MODULAR ARITHMETIC

A. MODULAR ARITHMETHIC
Modular arithmetic is a system of arithmetic for integers, where values reset to
zero and begin to increase again, after reaching a certain predefined value,
called the modulus (modulo).

a. Take for example the formula , where the difference of x and y is


divisible by n. In addition, we use the symbol “ ” to denote congruence
between x and y followed by mod n.

1. Example 1:

27 2 mod 5, where 27 is x, 2 is y and 5 is n. Following the equation


, then substitute the given numbers which then would be .
Considering the difference of 27 - 2 is divisible by 5, the congruence is
correct.

2. Example 2:

(15 + 18) mod 9. When you add 15+18 the sum will be 33, then dividing it
to 9 will give you a quotient of 3 and remainder 6. When we follow the
equation, the result will be . To make it congruent, the
standard form will be (15+18) mod 9 6.

B. IDENTITY AND INVERSE


The two arithmetic operations that will be featured here are the addition and
multiplication including their inverses. The identity element for additive is 0 and
the identity element for multiplicative is 1. For each integer m, is an integer b is
its additive inverse modulo n if m + b = 0 mod n. Similarly, b is multiplicative
inverse if (m)(b) = 1 mod n.
1. ADDITIVE INVERSE
a. Example 1:

Determine the value of the additive inverse of 9 mod 15.

Look for a number that when you add to 9 would result to 15. In this
case, 6 would do. 9 + 6 = 15 and this would result to 0. Thus,
. Another alternative statement would
be . Because when you add 6 to 9 the result would
be 15 and it is congruent since 15 divided by 15 would equal to 0.

2. MULTIPLICATIVE INVERSE

a. Example 1:

Determine the value of the multiplicative inverse of 3 mod 5.

Look for a number that when you multiply to 3 would have a remainder
of 1 when divided by 5. In this case, 2 would be the best answer since 2
multiplied to 3 would result to 6 and when it is divided by 5 it would get a
remainder of 1. Such that ( )( ) and it can also be
stated as

C. INTERNATIONAL STANDARD BOOK NUMBER (ISBN)


The International Standard Book Number (ISBN) is a numeric commercial book
identifier which is intended to be unique. Publishers purchase ISBNs from an
affiliate of the International ISBN Agency.

In the Philippines, the National Library of the Philippines (NLP) takes charge of
the ISBN registration, allocation and designation for Filipino publishers and
authors. The ISBN code’s format is
.
is the country code while the remaining digits except for are for
identifying the author and title of the book. is the check digit which can be
obtained using the formula:

(
)

If , then the check digit is 0.


a. Example 1:

Determine the check digit for 978-971-27-2769-__.

Using the formula given,

[ ( ) ( ) ( ) ( ) ( ) ( )]

= 10 – (154 mod 10)

= 10 – 4

=6

The check digit is 6.

D. UNIVERSAL PRODUCT CODE (UPC)

E. CREDIT CARDS
Credit cards can be checked by doubling every other digit in of the credit card
number. In this way, you can determine whether the card is valid or not. Simply
add every digit including the double ones, which are also to be treated
separately. The credit card number will only be valid when the sum of all the
digits under modulo 10 is congruent to 0.

a. Example 1:

5234 8213 3410 1298

To determine whether the credit card number is valid, we first have to create
a table.

DIGITS 5 2 3 4 8 2 1 3 3 4 1 0 1 2 9 8
DOUBLED 10 2 6 4 16 2 2 3 6 4 2 0 2 2 18 8
DIGITS(ALTERNATE)

Sum = 1 + 0 + 2 + 6 + 4 + 1 + 6 + 2 + 2 + 3 + 6 + 4 + 2 + 0 + 2 + 2 + 1 + 8 + 8
= 60 0 mod 10

Since, the sum of all the digits is congruent to 0; the credit card number is
valid.
II. BINARY SYSTEM AND HAMMING CODES
The most commonly used digits in the binary system are 1 and 0. Although, there
are instances where 0 – 9 is used and even letters A to F which are commonly used
in programming languages.

A. BINARY SYSTEM
The Binary System is a special system that uses the digits 0 and 1.

a. Example 1: (Decimal to Binary)

Consider the number 8610 and convert it to binary number.

Start by making a table that gradually divides 86 by 2. Also take note that in
getting the binary number, you start from the right which is why the binary
number for 86 is 1010110.

NEW 86 43 21 10 5 2 1
DECIMAL
QUOTIENT 43 21 10 5 2 1 0
REMAINDER 0 1 1 0 1 0 1

b. Example 2: (Binary to Decimal)


Convert the binary 101102 to Decimal number.

1 0 1 1 0
0 x 20 = 0
1 x 21 = 2
1 x 22 = 4
0 x 23 = 0
1 x 24 = 16
2210

B. BINARY SUM
Here are the sums of the elements:
SUM OF THE ELEMENTS BINARY SUM
0+0 0
0+1 1
1+0 1
1+1 10

2 is not a part of the binary system that is why 10 is the binary sum when you
add 1 to 1. The 2 digits which are 1 and 0 represent the value of 2.
a. Example 1:

C. BINARY CODES
Binary codes are strings of 1s and 0s. Each character in a string is called a bit
while a series of eight bits is called a byte.

KEY 5-BIT CODE


SPACE 00000
A 00001
B 00010
C 00011
D 00100
E 00101
F 00110
G 00111
H 01000
I 01001
J 01010
K 01011
L 01100
M 01101
N 01110
O 01111
P 10000
Q 10001
R 10010
S 10011
T 10100
U 10101
V 10110
W 10111
X 11000
Y 11001
Z 11010
a. Example 1

To figure out a message in the coded words you have to group them first by 5
bits.
0110100001101000100000000010011001100000001101010101110

01101 00001 10100 01000 00000 01001 10011 00000 00110 10101 01110

Using the table indicated above, the message is MATH IS FUN.

D. HAMMING CODES
The Hamming code is used for correcting errors. This uses a redundant bit or also
known as parity bit.

According to R.W. Hamming, we use parity bits in terms of .


will be found based on the following data bits in the table which would be
; will be based on ; will be based on
.

a. Example 1:
Consider the bit 10010. Each digit will be named
consecutively.

P1 P2 D3 P4 D5 D6 D7 D8
DIGIT ? ? 1 ? 0 0 1 0

To get , determine first the following data bits, which are 1,


0, and 1 consecutively. Adding the digits would result to 2. Now 2 is already
an even number, therefore, is 0. Follow the same rules for both
. then, is 0 and is 1.

III. CRYPTOGRAPHY
Cryptography has been an important factor by means of communicating through the
internet. It has been relied upon a widespread of websites that ensures your safety.

A. CRYPTOGRAPHY
Cryptography involves in securing your data or information by converting them
into codes or unreadable formats. This also involves encryption that encodes a
message or info that only authorized parties can access and decryption that
recovers the encrypted information.

a. Example 1:
ENCRYPTION
Encrypt the phrase “MATH RULES” using a shift cipher K = 9.
A B C D E F G H I J K L M
0 1 2 3 4 5 6 7 8 9 10 11 12
N O P Q R S T U V W X Y Z
13 14 15 16 17 18 19 20 21 22 23 24 25

Shift every letter from their assigned number on the table using the given
cipher formula which is C = (P + 9) mod 26.

C = (12 + 9) = 21 mod 26. 21 is V therefore the encrypt message of M is V.


The same goes for the other remaining letters.

Original M A T H R U L E S
Message
Original 12 0 19 7 17 20 11 4 18
Position
Shifted 21 9 2 16 0 5 20 13 27
Position
Encrypted V J C Q A F U N B
Message

b. Example 2:
DECRYPTION
Decrypt the phrase “GUNBLOFYM” using a shift cipher K = 20.
Use the formula P = (C – K) mod 26.

Original G U N B L O F Y M
Message
Original 6 20 13 1 11 14 5 24 12
Position
Shifted 12 0 19 7 17 20 11 4 18
Position
Encrypted M A T H R U L E S
Message

P = (6 – 20) mod 26
= -14 mod 26
-14 indicate that it is the additive inverse of 14 modulo 26. In this case,
-14 12 mod 26. The others will undergo the same process.

B. AFFINE CIPHER
This is basically cryptography made more complicated by adding multiplication
to make it more difficult to crack.
a. Example 1:
ENCRYPTION

C = (mP + K) mod 26 where m is the affine cipher.

Using the previous example, let m = 3 and K = 5.

C = (3*12 + 5) mod 26
C = (36 + 5) mod 26
C = 41 mod 26 = 15

The same process is applied to the remaining letters.

Original M A T H R U L E S
Message
Original 12 0 19 7 17 20 11 4 18
Position
Shifted 15 5 10 0 4 13 12 17 7
Position
Encrypted P F K A E N M R H
Message

b. Example 2:
DECRYPTION

We use the formula P = (C – K) mod 26, where is the affine cipher which
is also the multiplicative inverse of m.
Using the previous affine cipher, the inverse will be (9, 5). The formula will
now be P = 9 (C – 5) mod 26.

Cipher Y A J H O X A V J A J F R
Message
Original 24 4 5 20 20 21 4 15 5 4 5 19 3
Position
Shifted 15 17 0 24 5 14 17 12 0 17 0 22 8
Position
Encrypted P R A Y F O R M A R A W I
Message

P = 9 (24 – 5) mod 26
= 9(19) mod 26
= 171 mod 26 = 15
This process is the same for the remaining letters.
SOURCES
https://www.coursera.org/lecture/mathematics-for-computer-science/3-106-additive-identity-
and-inverse-mod-k-d5o4
https://whatis.techtarget.com/definition/Hamming-code
https://www.youtube.com/watch?v=1A_NcXxdoCc
https://en.wikipedia.org/wiki/Encryption
https://www.computerhope.com/jargon/d/decrypti.htm
MATHEMATICS IN THE MODERN WORLD, CHAPTER 8, 260 - 291

You might also like