transposition cipher text - scbaghdad.edu.iq · transposition cipher- to encrypt and decrypt...
TRANSCRIPT
1
Republic of Iraq
Ministry of Higher Education
And Scientific Research
Baghdad University
College of Science
Transposition Cipher Text
A project Report submitted to the college of Science, Baghdad University in partial fulfillment of the
Requirements for the B.Sc. Degree of Science in computer Science
By
Rafef Jamal
Zena Hussein
Supervised By
Dr. Sarab M. Hameed
2012 - 2011
2
الرحيم الرحمن هللا بسم
"ْالَحِكيمْ اْلَعلِيمُ أَنتَ كإنا َعّلْمَتَنا َما إاِلا َلَنا العلم ُسْبحاََنك َقالُوا "
العظيم هللا صدق
{ البقرة سورة: 23 يةاآل }
3
االهداء
الى القلب الحنون الرامز بالحب . . .
بالحب والحنان . . . الى السحاب الممطرة
التً تنسً قسوة الحٌاة . . . الكلمة الطٌبة الى
الى الٌد التً تعبت من اجل راحتً . . .
التً تنٌر لً دربً . . . الى اصحاب النصٌحة
الى من سهروا من أجلً . . .
والديا االحباء . . .
المهداة لً . . . الى الرحمة
ور الربانً التً تنٌر لً بصائري . . .الى مشكاة الن
ستظل بظلها . . .فروعها أل ة الطٌبة الممتدةالى الشجر
الى الشمس التً لم تغرب ٌوما فً حٌاتً . . .
زوجي العزيز. . .
. . . جوم التً تضًء لً اللٌالً الطوٌلةالى الن
اخوتي واخواتي. . .
الطوٌل . . .الى كل من ساندنً فً الدرب
اساتذتي . . .
4
االمتنان الى رئاسة القسم والهٌئة التدرٌسٌةٌتقدم طلبة المشروع بالشكر الجزٌل و
..ٌصالنا إلى هذا المستوى العلمً الرفٌع.دهم إلوبجه االذٌن ساهمو
اب مجٌد التً كانت لنا سر دم بفائق الشكر والتقدٌر لالستاذة الفاضلة د.وكذلك نتق
خطٌناها فً كل خطوة لما ابدته من توصٌات مثمرة وبناءة وارشادات قٌمة خٌرعون
النجاز هذا البحث .....
.... كذلك نود ان نشكر كل من مد ٌد العون لمساعدتنا فً انجاز هذا المشروع
ومن هللا التوفٌق .....
5
تأييد المشرف
كلٌة \علوم الحاسبات اؤٌد ان المشروع الموسوم قد اعد تحت اشرافً فً قسم
جامعة بغداد كجزء من متطلبات الحصول على درجة البكلورٌوس فً \العلوم
علوم الحاسبات
اسم المشرف :
التوقٌـــــــــع :
التـــــــــارٌخ :
تأييد لجنة المناقشة
لجنة المناقشة وقد تم اختبـــــــار نؤٌد اننا اطلعنا على المشروع الموسوم كأعضاء
فً محتوى التقرٌر وعلٌه --------------------------------------------الطالب
نوصً بقبول المشروع كبحث للتخرج للحصول على درجة البكلورٌوس فً علوم
الحاسبات .
االسم والتوقٌع االسم والتوقٌع االسم والتوقٌع االسم والتوقٌع
6
Summary
In cryptography, a transposition cipher is methods of encryption by
which the positions held by units of plaintext (which are commonly
characters or groups of characters) are shifted according to a regular
system, so that the cipher text constitutes a permutation of the plaintext.
That is, the order of the units is changed.
7
Table of Contents
Chapter One (Overview)
1.1. Introduction.………………………………………(9)
1.2. Cryptography…………………………………….(01)
1.3. Project Objective.……………………………….(12)
1.4. Project Layout.…………………………..……...(12)
Chapter Two (Transposition Cipher)
2.1. Introduction of transposition cipher...…………. (14)
2.2. Transposition technique……………………..…. (15)
2.2.1. Columnar transposition…………..……... (16)
2.2.2 Double transposition……………..………. (18)
2.3. Transposition cipher algorithms……………….. (19)
Chapter Three (Design and Implementation of
Transposition Cipher)
3.1. Introduction and form design view…………….. (24)
3.2. Experiments and Results………………………. (28)
3.3 Conclusions..…….………………………………. (41)
References
8
9
1.1. Introduction
Information security has been threatened by the information getting
to the hand of those for which it is not intended for. But how do we know
who the information is intended for? This question is answered by
encryption of message. Encryption of a message through the use of a
password makes it possible that only the person for whom a particular
message is intended for understands it; to others without the password it
is completely unintelligible.
In this wise, this project used an already existing algorithm-
transposition cipher- to encrypt and decrypt message through the use of a
means not yet used when the algorithm was developed the cryptosystem
to be used in a computer.
The computer which only understands certain languages must be
used to implement this transposition cipher, hence the use of a compiler
which serves as an intermediary between the high level language to a
machine language that can be only understood by the computer. The
Visual Basic language is used to developed software which when used to
encrypt message and decrypt message.
10
1.2. Cryptography
Security does not prevent unauthorized access to a system; it only makes
such access much difficult and this is what cryptology is known for. In
today's unsafe and increasingly wired world, cryptology plays a vital role
in protecting communication channels, databases, and software from
unwanted intruder [1].
Cryptology does not concern itself with the message not getting to
the intruders but making the message in the hand of the intruder
completely unintelligible to them. There exist many ways by which data
may be secured: they can be physical, early in history, all assets were
physical. Important information was all physical, as it was carved into
stone and latter written in paper. To protect these assets, physical security
was used, such as walls, moats, and guards. If the information was
transmitted, it usually went by messenger and usually a guard. The
Greeks of Classical times are said to have known of ciphers (e.g., the
scytale transposition cipher claimed to have been used by the Spartan
military). Herodotus tells us of secret messages physically concealed
beneath wax on wooden tablets or as a tattoo on a slave's head concealed
by new growth of hair, though these are not proper examples of
cryptography per se as the message, once known, is directly readable; this
is known as stenography [2]. The risk was purely physical, as there was
no way to get at the information without physically grasping it. In most
cases, if information was stolen, the original owner of the information
was deprived [3]. Besides the physical security used to protect data from
being accessed at all, means were adopted in which the physical access
were granted but the information is sent in a format that is unintelligible.
11
Machines were developed to make easy the job of encryption/decryption
designed amongst which was the German Lorenz cipher machine, used in
World War II (WWII) for encryption of very high-level general staff
messages, The Enigma machine, used, in several variants, by the German
military between the late 1920s and the end of World War II,
implemented a complex electro-mechanical polyalphabetic cipher to
protect sensitive communications. Breaking the Enigma cipher at the
Biuro Szyfrów, and the subsequent large-scale decryption of Enigma
traffic at Bletchley Park, was an important factor contributing to the
Allied victory in WWII. [3].
The development of digital computers and electronics after WWII
made possible much more complex ciphers. Furthermore, computers
allowed for the encryption of any kind of data represent able within
computers in any binary format, unlike classical ciphers which only
encrypted written language texts. Thus, computers supplanted linguistic
cryptanalytic approaches. Many computer ciphers can be characterized
by their operation on binary bit sequences (sometimes in groups or
blocks), unlike classical and mechanical schemes, which generally
manipulate traditional characters (i.e., letters and digits) directly.
However, computers have also assisted cryptanalysis, which has
compensated to some extent for increased cipher complexity.
Nonetheless, good modern ciphers have stayed ahead of cryptanalysis; it
is typically the case that the use of a quality cipher is very efficient (i.e.,
fast and requiring few resources), while breaking it requires an effort
many orders of magnitude larger than before, making cryptanalysis so
inefficient and impractical as to be effectively impossible.
12
1.3. Project Objective
The use of computers in cryptology is yet to be fully utilized. This work
is intended to use the computer as a tool for cryptography. This can be
achieved via the use of software programming language that employs the
use of the already existing columnar and double transposition ciphering
algorithm. The columnar and double transposition ciphering scheme
which used to be manually done will become a process achieved through
the use of software programmed in Visual Basic. The program will do the
encryption/decryption of information.
1.4. Project Layout
This project is organized as follows:
Chapter two present the basic of transposition cipher, its types, and the
algorithm for encryption and decryption of transportation cipher.
Chapter three demonstrates the design of transposition chipper and its
results.
13
14
2.1. Introduction
In cryptography, a transposition cipher is a method of encryption
by which the positions held by units of plaintext (which are commonly
characters or groups of characters) are shifted according to a regular
system, so that the ciphertext constitutes a permutation of the plaintext.
That is, the order of the units is changed. Mathematically a bijective
function is used on the characters positions to encrypt and an inverse
function to decrypt. Following are some transposition cipher techniques:
Rail Fence cipher
Route cipher
Columnar transposition
Double transposition
Myszkowski transposition
Disrupted transposition
Grilles
Detection and cryptanalysis
Combinations
Fractionation
15
2.2. Transposition cipher
The transposition cipher is an already existing conventional
encryption technique. It has the algorithm as:
Step 1: Choice of a password
Step 2: The plaintext must be known
Step 3: A table is drawn with column equal to the number of alphabet in
the password with rows that are sufficient to accommodate all the
characters of the plaintext.
Step 4: The password is arranged in such a way as to its occurrence in
the alphabet i.e. the alphabet closest to letter “a” is assigned the first
position in whatever column it is.
Step 5: The positions of the alphabet is used to print out the text. The
alphabet in the column corresponding to the alphabet arrangement is read
first and the process is continued till all the password position has been
exhausted.
A reverse of this process is used in decryption.
16
2.2.1. Columnar Transposition
In a columnar transposition, the message is written out in rows of a
fixed length, and then read out again column by column, and the columns
are chosen in some scrambled order. Both the width of the rows and the
permutation of the columns are usually defined by a keyword. For
example, the word ZEBRAS is of length 6 (so the rows are of length 6),
and the permutation is defined by the alphabetical order of the letters in
the keyword. In this case, the order would be "6 3 2 4 1 5".
In a regular columnar transposition cipher, any spare spaces are
filled with nulls; in an irregular columnar transposition cipher, the spaces
are left blank. Finally, the message is read off in columns, in the order
specified by the keyword. For example, suppose we use the keyword
ZEBRAS and the message WE ARE DISCOVERED FLEE AT ONCE.
In a regular columnar transposition, we write this into the grid as:
6 3 2 4 1 5
W E A R E D
I S C O V E
R E D F L E
E A T O N C
E XXXXX
Provide five nulls (XXXXX) at the end. The cipher text is then
read off as: EVLNE ACDTK ESEAQ ROFOJ DEECU WIREE
In the irregular case, the columns are not completed by nulls:
6 3 2 4 1 5
W E A R E D
I S C O V E
R E D F L E
E A T O N C
E
17
This results in the following cipher text:
EVLNA CDTES EAROF ODEEC WIREE
To decipher it, the recipient has to work out the column lengths by
dividing the message length by the key length. Then he can write the
message out in columns again, and then re-order the columns by
reforming the key word.
Columnar transposition continued to be used for serious purposes
as a component of more complex ciphers at least into the 1950s.
18
2.2.2 Double transposition
A double transposition was often used to make the cryptography
stronger. This is simply a columnar transposition applied twice. The same
key can be used for both transpositions, or two different keys can be used.
As an example, we can take the result of the irregular columnar
transposition in the previous section, and perform a second encryption
with a different keyword, STRIPE, which gives the permutation
"564231":
5 6 4 2 3 1
E V L N A C
D T E S E A
R O F O D E
E C W I R E
E X X X X X
As before, this is read off column wise to give the cipher text:
CAEEN SOIAE DRLEF WEDRE EVTOC
If multiple messages of exactly the same length are encrypted using the
same keys, they can be anagrammed simultaneously. This can lead to
both recovery of the messages, and to recovery of the keys (so that every
other message sent with those keys can be read).
19
2.3. Transposition Cipher Algorithms
This section illustrates the encryption, decryption for columnar and
transposition cipher.
Encryption algorithm (Columnar Transposition)
Step 1: The password is small alphabet
Step 2: Each Alphabet of the password is converted into their ASCII
Code equivalent. This makes it easy to find that the alphabet which
comes first. This is found by finding the minimum of the alphabet and
replacing the minimum found with the highest possible ASCII code.
Step 3: The length of the plaintext length is found.
Step 4: The length of the password and the length of the plaintext is used
to determine the number of rows that will be created as the number of
column is already known as the number of the password letters.
Step 5: Exceptions are used to complete rows that are not completely
filled with alphabet.
Step 6: The plaintext is arranged into an array size determined in step 4.
Step 7: the columns are read with respect to the positions determined in
step 2.
Step 8: this gives the encrypted message.
20
Encryption algorithm (Double Transposition)
Step 1: The password is small alphabet
Step 2: Each Alphabet of the password is converted into their ASCII
Code equivalent. This makes it easy to find that the alphabet which
comes first. This is found by finding the minimum of the alphabet and
replacing the minimum found with the highest possible ASCII code.
Step 3: The length of the plaintext length is found.
Step 4: The length of the password and the length of the plaintext is used
to determine the number of rows that will be created as the number of
column is already known as the number of the password letters.
Step 5: Exceptions are used to complete rows that are not completely
filled with alphabet.
Step 6: The plaintext is arranged into an array size determined in step 4.
Step 7: the columns are read with respect to the positions determined in
step 2.
Step 8: this gives the encrypted message and then back to step 1 and
repeat step 2, 3, 4,5,6,7
Step 9: this gives the encrypted message with second password.
21
Decryption algorithm (Columnar Transposition)
This is just the reverse of the encryption algorithm. Step1 - 2 is the same
as that in encryption algorithm.
Step 3: the length of the cipher text and password are used to determine
the number of alphabet that would be placed in the columns determined
by the password arrangement
Step 4: there are exception cases introduced.
Step 5: the plaintext is achieved by reading the alphabets row by row.
Decryption algorithm (Double Transposition)
This is just the reverse of the encryption algorithm. Step1 - 2 is the same
as that in encryption algorithm.
Step 3: the length of the cipher text and password are used to determine
the number of alphabet that would be placed in the columns determined
by the password arrangement
Step 4: there are exception cases introduced.
Step 5: the plaintext with first password is achieved by reading the
alphabets row by row then back to step 1 and repeat step 2, 3, 4.
Step 6: the plaintext is achieved by reading the alphabets row by row.
22
Figure (2.1) is a simplified flow chart representation of the transposition
cipher for encryption and decryption process
START
ENCRYPT? PROCESS ENCRYPTION
PROCESS DECRYPTION
DO YOU WISH TO CONTINUE?
END
YES
N
O
NO
YES
Figure 2.1 Encryption and decryption process
The first thing to be determined is whether the user wants to perform
an encryption or decryption process. Based on the option selected, the
process will be performed an output whether plaintext or cipher text will
be produced which corresponds to the option chosen in this case
decryption and encryption respectively.
23
24
3.1 Introduction
The software Designed in VB is divided into two parts:
The Form Design: these are forms used to create the windows application
package
FORM DESIGN VIEW
Form 1: interface form contains start command to begin the program
as shown in figure 3.1.
Figure 3.1: Start Form
In Form 2 contains two menus including file and transposition as depicts
in figure 3.2
Figure 3.2: Transposition cipher form
25
First: select to open or save the file or end the program a in figure 3.3
Figure 3.3: select open or save file or exit the program
Second: select the type of the encryption and decryption in figure 3.4
Figure 3.4: select the type of the encryption and decryption
26
In form 3 the key and the plain text must be entered then the command
encryption is pressed to display the cipher text. The other command for
decryption is used to return the cipher text to plain text. Also, the form 3
contains command save to the result to file and command exit to return to
form2. Figure 3.5
Figure 3.5: encryption and decryption with one key
27
The form 4: contains text for the 1st and 2
nd keys , text for the plain text ,
two command one for encryption to display the cipher text and the other
command for decryption to display the plaintext. Form4 contains
command save to save the result and command to exit to return to form 2.
Figure 3.6
Figure 3.6: encryption and decryption of tow key
28
3.2Experiments and Results
Example 1: figure 3.7
Key: key
Plain text: computer
Cipher text: ourcpemtX
Decipher text: computerX
Figure 3.7: example encryption and decryption with one key
Save the result: figure 3.8
Figure 3.8: save the rustle of decryption of one key
29
Figure 3.9: save to file
Open a plain text from file: figure 3.10
Figure 3.10: open plaintext
Figure 3.11: open plaintext from file
30
Example 2: figure 3.12
Key: good
Plain text: computer
Cipher: prcuotme
Decipher: computer
Figure 3.12: example of encryption and decryption of one key
Example 3: figure 3.13
Key: aaaa
Plain: computer
Cipher: cuotmepr
Decipher: computer
Figure 3.13: example of encryption and decryption of one key
31
Example 4: figure 3.14
Key: akea
Plain: computer
Cipher: cuprmeot
Decipher: computer
Figure 3.14: example of encryption and decryption of one key
32
Experiments and result two key:
Example 1: figure 3.15
Key 1: bad
Key 2: key
Plain: computer
Cipher 1: ourcpemt
Cipher 2: uptocmre
Decipher 1: ourcpemt
Decipher 2: computer
Figure 3.15: example of encryption and decryption of two key
Save the result: figure 3.16
Figure 3.16: save the rustle of decryption of two key
33
Figure 3.17: save the rustle of decryption of two key to file
Open file to get the plain text : figure 3.18
Figure3.18: Open file to get the plain text
Figure3.19: Open file to get the plain text from file
34
Example 2:figure 3.20
Key 1: good
Key 2: baye
Plain: computer
Cipher 1: prcuotme
Cipher 2: rtpouecm
Decipher 1: prcuotme
Decipher 2: computer
Figure3.20: example of encryption and decryption of two key
35
Example 3: figure 3.21
Key 1: baye
Key 2: good
Plain: computer
Cipher 1: otcuprme
Cipher 2: ueoptrcm
Decipher 1: otcuprme
Decipher 2: computer
Figure3.21: example of encryption and decryption of two key
36
Example 4: figure 3.22
Key 1: good
Key 2: seed
Plain: computer
Cipher 1: prcuotme
Cipher 2: uretcmpo
Decipher 1: prcuotme
Decipher 2: computer
Figure 3.22: example of encryption and decryption of two key
37
Example 5: figure 3.23
Key 1: aaaa
Key 2: asdf
Plain: computer
Cipher 1: cuotmepr
Cipher 2: cmoptrue
Decipher 1: cuotmepr
Decipher 2: computer
Figure3.23: example of encryption and decryption of two key
38
Example 6: figure 3.24
Key 1: asdf
Key 2: aaaa
Plain: computer
Cipher 1: cumeprot
Cipher 2: cpurmoet
Decipher 1: cumeprot
Decipher 2: computer
Figure3.24: example of encryption and decryption of two key
39
Example 7: figure 25
Key 1: aaaa
Key 2: aaaa
Plain: computer
Cipher 1: cuotmepr
Cipher 2: cmueoptr
Decipher 1: cuotmepr
Decipher 2: computer
Figure 3.25: example of encryption and decryption of two key
40
Example 8: figure 3.26
Key 1: aaaa
Key 2: bbbb
Plain: computer
Cipher 1: cuotmepr
Cipher 2: cmueoptr
Decipher 1: cuotmepr
Decipher 2: computer
Figure3.26: example of encryption and decryption of two key
41
3.3 CONCLUSIONs
It will be seen that the result obtained from the decryption is slightly
different from the original text this is because the space that was in the
original message was removed as it might weaken the encryption
algorithm .it is recommended to further improve this algorithm that the
space be replaced by any special characters during encryption and this
should be done in a consciousness of the decryption algorithm..
Transposition cipher may be viewed as an obsolete encryption
cipher but no matter how obsolete it appears it still has its merit. No
matter how strong an encryption tool may prove when it is discovered
that is the scheme used it defeats its purpose. To this end the users of this
software will not in the slightest be told that the software operates using
transposition cipher. If not told it can be any cipher algorithm. The
password must be held in high esteem as it is the key to this encryption
and decryption process. VB has been used to transform the transposition
cipher which was done manually to a software program that can use
anywhere information security is of paramount importance.
42
REFERENCES
[1] Stamper, David, “Essential of Data Communication”, Saratoga
Group
[2] Eric Maiwald, “Network Security a Beginner’s Guide”, Second
Edition, McGraw Hill, Osborne, 2003.
[3] Wikipedia Encyclopedia, available at
http://en.wikipedia.org/wiki/historyofcrytography
[4]Ed Tittel, “Theory and Problems of Computer Networking”, McGraw
Hill, Osborne, 2002
[5] R.I Salawu & S.O Adetona, “The Art and Science of Secured
Communication”, Institute of Security of Nigeria, Nigeria 2007
[6]James Irvine & David Harie, “Data Communications & Network: An
Engineering Approach”, John Wiley & Sons ltd., 2002
[7] Gilman, Larry "Cipher Machines." Encyclopedia.com. 2 Sep. 2009
available at:
<http://www.encyclopedia.com>.
[8] Brian J. Winkel, Cipher A. Deavours, David Kahn, and Louis Kruh
“The German Enigma Cipher Machine: Beginnings, Success, and
Ultimate Failure”, Artech House, August 2005.
[9] Tyma Paul, “Software Development Secure”, Start Newsletter, Feb
2003.
[10] Sigmon Richard, www.articlearchives.com , 2007
[11] Madsen Wayne, “An International Survey of Encryption Policy”,
1998
[12] Tabor Bob, Learn Visual Studio, www.learnVisualstudio.Net ,
2005.
[13] S.O Adetona, “Messages Secrecy in Electioneering environment”,
proceedings of Institute of Security, Nigeria,2009
43
العراق جمهورٌة العالً التعلٌم وزارة
العلمً والبحث بغداد جامعة
العلوم كلٌة
والشفرات النص تبديل
الحصول على درجة من متطلبات كجزء بغداد العلوم جامعة لكلٌة المشروع المقدمتقرٌرعن
حاسباتال البكلورٌوس فً علوم
خالل من المقدم
جمال رفٌف
حسٌن زٌنة
اشراف تحت
حمٌد مجٌد سراب. د
2012 - 2011