Citation
Development and application of data encryption using a data shuffling technique

Material Information

Title:
Development and application of data encryption using a data shuffling technique
Creator:
Norris-Saucedo, Steven Joseph
Publication Date:
Language:
English
Physical Description:
vii, 94 leaves : illustrations ; 29 cm

Thesis/Dissertation Information

Degree:
Master's ( Master of science)
Degree Grantor:
University of Colorado Denver
Degree Divisions:
Department of Electrical Engineering, CU Denver
Degree Disciplines:
Electrical engineering

Subjects

Subjects / Keywords:
Cryptography ( lcsh )
Data transmission systems -- Security measures ( lcsh )
Computers -- Access control ( lcsh )
Computers -- Access control ( fast )
Cryptography ( fast )
Data transmission systems -- Security measures ( fast )
Genre:
bibliography ( marcgt )
theses ( marcgt )
non-fiction ( marcgt )

Notes

Bibliography:
Includes bibliographical references (leaf 47).
General Note:
Submitted in partial fulfillment of the requirements for the degree, Master of Science, Department of Electrical Engineering.
Statement of Responsibility:
Steven Joseph Norris-Saucedo.

Record Information

Source Institution:
University of Colorado Denver
Holding Location:
Auraria Library
Rights Management:
All applicable rights reserved by the source institution and holding location.
Resource Identifier:
22927369 ( OCLC )
ocm22927369
Classification:
LD1190.E54 1989m .N67 ( lcc )

Full Text
DEVELOPMENT AND APPLICATION OF
DATA ENCRYPTION USING
A DATA SHUFFLING TECHNIQUE
by
Steven Joseph Norris-Saucedo
B.S., University of New Mexico, 1985
A thesis submitted to the
Faculty of the Graduate School of the
University of Colorado in partial fulfillment
of the requirements for the degree of
Master of Science
Department of Electrical Engineering
1989


This thesis for the Master of Science degree by
Steven Joseph Norris-Saucedo
has been approved for the
Department of
Electrical Engineering
by
Date.
£ ^ }\) D O j $ J


iii
Norris-Saucedo, Steven Joseph
Development and Application of Data Encryption using
a Data Shuffling Technique
Thesis directed by Professor Douglas A. Ross
Data encryption has been used to ensure the
security of data for many years and in many fashions.
This paper discusses a technique of data encryption
derived from an algorithm for shuffling cards,
producing a simple procedure that has potential for
many variations to make the encryption more and more
difficult to decipher. A brief discussion of a similar
encryption technique previously used is followed by the
development of the card shuffling technique and its
integration into a procedure for encrypting ASCII
character strings and entire ASCII files. Finally, the
unusual relationship between the length of the data
strings, referred to as data decks, and the number of
shuffles needed to fully recover the original order of
the data deck is investigated.
The form and content of this abstract are approved. I
recommend its publication.
Signed


DEDICATION
With love and admiration to Nancy Norris-Saucedo, my
parents and family, and Jeff Stevens. There are many
parts to this puzzle, and they are all necessary for
what becomes the final picture. Thank you.


V
CONTENTS
CHAPTER
I. INTRODUCTION................................... 1
II. DEVELOPMENT OF SHUFFLING TECHNIQUE........... 5
Shuffling 52 Cards......................... 5
Shuffling other Size Decks................... 9
III. APPLICATIONS IN BASIC....................... 11
Single Deck Encryption...................... 11
Multi-Deck Encryption....................... 22
IV. APPLICATIONS IN C........................... 27
Advantages ................................. 27
Multi-Deck Encryption..................... 30
ASCII File Encryption....................... 33
V. INVESTIGATION OF DERIVED NUMBER PAIRS......... 36
IV. CONCLUSION.................................... 44
REFERENCES........................................ 47
APPENDIX
A. SHUFFLING 52 CARDS............................ 48
B. BASIC PROGRAM LISTINGS........................ 51
C. C PROGRAM LISTINGS............................ 63
D. CARDS/SHUFFLES PAIRS TABLE.................... 85


vi
TABLES
Table
1. Lengths Causing Exact Reversal.......... 15
2. Deck Sizes as Percentage of Original
Length, BASIC Code...................... 23
3. Deck Sizes as Percentage of Original
Length, C Code.......................... 32
4. Number of Points Between y = x-2 and
y = (x-2 )/2............................ 39
5. Linearities in Number of Shuffles.... 41


vii
FIGURES
Figure
1. Flow Diagram For Shuffling
Algorithm............................... 8
2. Deck Sizes vs. Shuffles, 2-400......... 17
3. Flow Diagram for Givel.bas............. 19
4. Deck Size vs. Shuffles, 2-3000......... 37
5. Data Forming Line Patterns............. 38
6. Expanded Plot of 1500 Points........... 40


CHAPTER I
INTRODUCTION
Encryption is the process of converting
intelligible text into unintelligible text. Together
with decryption, which converts the encrypted text back
into intelligible text, the method and process known as
cryptography is defined.1 The need for data encryption
has been accepted for hundreds of years. Well before
there were computers, there were methods of masking the
contents of written material in such a way that a
special scheme had to be employed to reverse the
masking process and retrieve the original message. Any
information perceived as being sensitive in nature,
whether it be issues involving national security or the
secret location of the after-school meeting place,
requires some method of encryption if that information
is to remain confidential. The advent of the computer
has both aided in and increased the need for data
encryption. By automating the encryption and
decryption processes, those processes can be done
faster and more efficiently than ever before. On the
other hand, the use of computers as hosts for many
1. Harry Katzan, Jr., The Standard Data Encryption
Algorithm, (New York, Petrocelli, 1977) p. 16


2
users with possible access to sensitive information has
increased the need for more and more types of data
security schemes.
There are several techniques for data
encryption, ranging from the simplistic to the very
elaborate. A sophisticated technique is not
necessarily a requirement. If the message is
intercepted, the unauthorized party should either not
know how to decrypt the message, or feel it would be
counterproductive to decrypt the message. Essentially,
the technique used should be one such that the time and
effort needed to recover the original message is worth
more than the content of the message itself.
One of the simplest techniques for data
encryption is known as transposition. With this
technique, the data is rearranged in some reversible
fashion, such that the individual characters retain
their identity, but their position is altered. An
example is a reversal of all characters in the message.
Consider the following character string:
"NOW IS THE TIME FOR ALL AROUND"
The encrypted string, when reversed, becomes
"DNOURA LLA ROF EMIT EHT SI WON"
The decryption process would involve reversing
the character string again, thereby undoing the
encryption process, and the original message would be
recovered.


3
Another example of data encryption is called
cipher substitution. With this scheme, the individual
characters retain their position, but their identity is
altered. An example of this would be to shift the
plain text alphabet one character to the left, which
changes
ABCDEFGHIJKLMNOPQRSTUVWXY Z
to
BCDEFGHIJKLMNOPQRSTUVWXY ZA
This is called the cipher text alphabet. With this,
the message
"NOW IS THE TIME FOR ALL AROUND"
becomes
"OPX JT UIF UJNF GPS BMM BSPVOE"
A key word is sometimes used to further enhance the
substitution cipher. The unique letters of the key
word are placed at the beginning of the cipher text,
and the remaining letters of the plain text alphabet
are added to the key word to make the cipher text
alphabet. For example, if the key word ENGLAND is
used, then the cipher text alphabet becomes
ENGLADBCFHIJKMOPQRSTUVWXYZ
and the popular message
"NOW IS THE TIME FOR ALL AROUND"
now becomes
"MOW FS TCA TFKA DOR EJJ EROUML"


4
A variation of the transposition technique is
the thrust of this paper. However, unlike the
transposition example, this variation does not stop the
altering of the character location after one movement,
but rather after a series of movements, the number of
which is a function of the length of the character
string. Also unlike the example, the encryption
process is not reversed during decryption. Instead,
decryption is the continuation of the encryption
process where, in a predictable fashion, the original
order of the character string can be recovered. The
relationship between the length of the character string
and the number of iterations needed to recover the
original order is nonlinear, and adds to the complexity
of breaking the algorithm without adding to the
complexity of the algorithm itself.


5
CHAPTER II
DEVELOPMENT OF SHUFFLING TECHNIQUE
Shuffling 52 Cards
The question posed is a simple one: If a
52-card deck of cards is split into two equal decks and
shuffled "perfectly", that is, one card alternately
from each deck, will the deck return to its original
order if the perfect shuffling is continued, and if so,
how many shuffles are needed? The answer to the first
part of the question is, as one might suspect, yes, the
deck of cards will eventually return to its original
order. As to the number of shuffles that are required,
intuitively one would suspect a large number, say 52 or
perhaps 104. Surprisingly, the number of shuffles
needed to restore a deck of cards of size 52 is 8.
This was determined by writing a program in
BASIC on a DELL System 200, which is an IBM-compatible
PC. The program, named "cards.bas", fills two arrays
of size 52 with unique integer values from 1 to 52.
The arrays were labeled "main_l" and "main_2", and
represented the deck of cards. "main_l" held the
)
original order of the deck, and "main_2" was to be the
array that was "shuffled". The program then took the


6
values stored in main_2 and loaded two smaller arrays,
"sub_l" and ,,sub_2,,. Both of the smaller arrays were
half the size of main_2, and represented splitting the
deck of cards in half. The intent was to load sub_l
with the values from main_2[l] through main_2[26], and
to load sub_2 with the values from main_2[27] through
main_2[52]. This was done in one FOR loop, with the
following algorithm:
FOR i = 1 to 26
sub_l[i] = main_2[i]
sub_2[i] = main_2[i + 26]
NEXT i
Once the two smaller arrays were loaded, main_2 was
reloaded from sub_l and sub_2, using the following
algorithm to "shuffle" the two arrays:
FOR i = 1 to 26
main_2[2*i 1] = sub_l[i]
main_2[2*i] = sub_2[i]
NEXT i
In this manner, main_2[l] = sub_l[l], main_2[2] =
sub_2[1], main_2[3]=sub_l[2], main_2[4] = sub_2[2] and
so on until main_2 is completely refilled. With this
concept of perfect shuffling, the first and last
elements in the original array will always remain in
their respective positions.


7
Finally, the shuffled main_2 was compared to
main_l, which held the original order of the cards.
The two arrays were considered equal if, for every ith
element, main_l[i] = main_2[i]. The variable cnt was
used to sum the number of times the shuffling was done.
If the arrays were not equal, then cnt was incremented
and the process repeated, starting with splitting
main_2 into sub_l and sub_2, shuffling the two smaller
arrays back into main_2, and comparing main_2 with the
original order of the array held in main_l. If the two
arrays were equal, then the process was stopped, and
the cnt was checked.
Figure 1 is a flow diagram of the procedure
for determining the number of shuffles needed to
recover the original order.


8
FIGURE 1
FLOW DIAGRAM FOR SHUFFLING ALGORITHM
In order to confirm that the number of
shuffles needed for a 52 card deck to recover its
original order was actually 8, additional code was
added to output the contents of array main_2 at each of
the intermediate steps. After inspecting the array at
each step, it was confirmed that the deck recovered its
original order after 8 shuffles. Appendix A shows the
array elements of main_2 at the different number of
shuffles, from 1 to 8.


9
Shuffling Other Size Decks
The natural progression was to determine the
number of shuffles needed for various "data deck
sizes. Still on the DELL PC, the same code that
generated the shuffling for the 52-card deck was used
in a loop to check data decks of size 2 to size 400.
400 was chosen as a maximum data deck size because of
the time involved for the PC to compute the number of
shuffles needed, and because of memory constraints.
The DELL PC, which runs with an INTEL 80286 processor,
took over 1-1/2 hours to compute the shuffles needed
for all of the data decks from size 200 to size 400.
One constraint put on the algorithm was that
all data decks had to be of even size. One of the
major components of the algorithm is to split the deck
in half, and a method for shuffling an odd-size data
deck was not derived. When the code was eventually
used for data decks of unknown size, the constraint was
dealt with in several ways which are described later.
Two BASIC programs were written. The first
program, cards.bas", accepted an even number between 2
and 400, inclusive, from the terminal, determined the
size of the data deck to be shuffled, and returned the
number of shuffles needed. The second, cards2.bas",
looped through the shuffling algorithm, checking


10
even-sized data decks from 2 to 400, and saved the
decksize/shuffles pairs in a file "shuffle". This file
was then used as a look-up table for subsequent code.


11
CHAPTER III
APPLICATIONS IN BASIC
Single Deck Encryption
Once the number of shuffles needed for a given
size data deck was determined, the shuffling technique
could be used for data encryption in the following way:
1. Accept a character string of any length up to
the largest data deck size for which the number
of shuffles needed for recovery is known. On
the DELL PC, this limited the character string
to 400. Actually, BASIC would only allow
character strings no longer than 254 to be
input from the terminal.
2. Treat the character string as a data deck, with
each individual character considered one "card"
of the deck.
3. From the file "shuffle", which contains the
decksize/shuffles pairs, determine the number
of shuffles needed for full recovery of the
given data deck. Using this look-up approach
saves the time of executing the shuffling
algorithm more times than is necessary.


12
4. Using the shuffling algorithm, shuffle the data
deck, but not to full recovery, but rather to
half the number of shuffles needed. The data
string is now encrypted as a function of its
own length, and in a sense, the algorithm
fluctuates because the number of shuffles
needed fluctuates in such an unpredictable
manner.
5. Save the encrypted data deck in a file.
6. Read the file containing the encrypted data
deck with a second piece of code. This code
will determine the length of the data deck, the
number of shuffles needed to recover the
original order, and will shuffle the data deck
accordingly. With that accomplished, the
original data deck will have been recovered.
The first part of the code, again written in BASIC on
the DELL PC, was called "givel.bas", and fulfilled the
first five of the steps outlined above. There were
several obstacles to overcome in order to successfully
encrypt the data deck. First, because the algorithm
can only handle even size decks, the data deck had to
be adjusted in size if its size was odd. This was done
by adding a blank character to the end of the string,
which had no effect on the actual data itself. With
all data decks now assured to be even, either by their
original length or by adding a blank character, the


13
decks could be shuffled as before, with each character
being loaded into an element array. The array was then
shuffled half of the necessary number needed for
recovery, and saved in a file called "send". As a
check that the data deck was indeed encrypted, the
encrypted deck was displayed on the screen before it
was saved to the file.
Another problem that needed consideration was
the fact that not all of the number of shuffles needed
for a given length was even. For example, if the data
deck is of size 50, the number of shuffles needed is
21. When the algorithm tried to shuffle to half the
number needed, it had a difficult time shuffling 10.5
times. Rather than try to find a way of actually
shuffling one-half of one complete shuffle, it was
decided to subtract l from the number of shuffles
needed, and shuffling to half of that amount. For the
example discussed above, that would result in shuffling
10 times. The receiving code would then take that
offset into account when determining the number of
shuffles to perform to recover the data deck. The
algorithm was as follows:
If (no_shuffles is odd)
END1 = (no_shuffles 1) /2
else
END1 = no_shuffles/2
endif


14
where END1 was the number of shuffles the "givel.bas"
code would shuffle the data deck before saving the
encrypted string to a file.
As the code was being tested for various data
deck lengths, a curious result would occur in a
seemingly random fashion. With certain size data
decks, the encrypted code would be exactly reversed,
with the exception of the first and last characters
which always remain in their respective positions
throughout the shuffling, and could actually be read
backwards. For example, a character string of length
30, such as:
"Now is the time for all around"
requires 28 shuffles for full recovery, and when
shuffled 14 times, would result in the string:
"Nnuora 11a rof emit eht si wod"
The exact reversal was even more apparent when the
original data deck was an odd length, and a blank
character was added to the end of the string. In that
case, it was the blank character remaining at the end
of the encrypted string, with a result that was easily
decipherable. For example, the character string:
"Now is the time for all great"
has a length of 29, which is increased to 30 by the
shuffling algorithm. After shuffling 14, the encrypted
string is:
"Ntaerg 11a rof emit eht si wo"


15
Again, only certain data deck lengths would
produce this result, which was considered unacceptable
as encrypted code. After several tests, it was
discovered that the exact reversal occurred for the
lengths listed in Table 1.
Length No. Shuffles
12 10
14 12
20 18
30 28
38 36
54 52
60 58
TABLE 1
LENGTHS CAUSING EXACT DECK REVERSAL
These pairs all had two related characteristics
in common: 1) They were all of the form y = x 2,
where y was the number of shuffles needed for complete
recovery of the data deck and x was the length of the
data deck, and 2) They all represented the largest
number of shuffles needed for recovery for lengths up
to that particular size.
It was found that the data deck/shuffles pairs
that produced the exact reversal of the data deck, when
shuffled half-way to complete recovery, were those
pairs producing "peaks" when graphed, and those peaks
were along the line y = x 2. Figure 2 shows the


16
graph of lengths versus shuffles for lengths from 2 to
400, and the line along which the data deck was exactly
reversed when shuffled half-way to complete recovery.


400
300
200
100
0
of Shuffles
i
_L
100 200 300 400
Deck Size
FIGURE 2
DECK SIZES VS. SHUFFLES 2-400


18
In order to encrypt the data deck in such a way
that it would never result in the exact reversal of the
data, the deck was shuffled not to exactly halfway, but
rather to (halfway 1). For example, the 30 character
data deck which requires 28 shuffles for full recovery
was shuffled 13 times rather than 14. Also, instead of
having a special piece of code for those particular
lengths where this problem occurred, all lengths were
handled in this manner, eliminating the need for extra
code. The algorithm for the number of shuffles
"givel.bas" would perform was then modified
to the following:
if (no_shuffles is odd)
END1 = (no_shuffles l)/2
else
END1 = (no_shuffles/2) 1
endif
Figure 3 shows the flow diagram for "givel.bas".


19
FIGURE 3
FLOW DIAGRAM FOR GIVE1.BAS
Once the shuffling algorithm was acceptable for
overcoming the problems of odd number of shuffles
needed and of exact reversal of the data deck, the next
step was to generate the code which would read the file
where the encrypted string was stored, determine its
size and the number of shuffles needed for recovery,
and perform the necessary shuffles, thereby recovering
the original data deck. This code was named


20
"getl.bas", and was actually easier to generate than
"givel.bas" in that there were no new problems to
overcome.
When the encrypted character string was read
from the file "send", its length was again checked, to
assure that the length was even. It was not assumed
that the blank character placed at the end of the data
deck by "givel.bas", if it was needed, was actually
saved with the encrypted string. Once the length was
determined, the file "shuffle", which was loaded with
the "cards2.bas" program with the decksize/shuffles
pairs, was used as a lookup table to determine the
number of shuffles needed for full recovery of the data
deck. As with "givel.bas", adjustments had to be made
if the number of shuffles was odd. Specifically, the
variable START1 had to be derived, which would be one
greater than the number of shuffles performed by
"givel.bas". If the number of shuffles needed was odd,
then "givel.bas" had shuffled the data deck
(no_shuffles l)/2 times, and START1 was set at
(no_shuffles l)/2 + 1. Otherwise, the number of
shuffles needed was even, and "givel.bas" had shuffled
the data deck (no_shuffles/2) 1, and START1 was set
at (no_shuffles/2). With START1 determined, the code
looped through the shuffling algorithm from START1
until the total number of shuffles needed was reached.


21
This continued the shuffling from "givel.bas" and
recovered the original data deck. The data deck was
then displayed on the screen.
The following is an example of the encrypted
message generated by "givel.bas". The character string
used for input for the program was:
Part 1 of the encryption will take the given
string, determine how many shuffles are neeeded for
the entire string to be encrypted at one time,
shuffle the deck to the half-1 point, and save
A carriage return was not used until the end of the
string because BASIC uses carriage returns as markers
for the end of the input. The program determined the
length of the string was 189 characters and, because
the length was odd, added one blank character to the
end of the string. This changed the length of the
string to 190. From the file "shuffle", the number of
shuffles needed for a data deck of length 190 was found
to be 18. The program then shuffled the deck a total
of eight times, which is one less than one-half of the
number needed. The encrypted message that was saved in
the file "send" was:
Pskiertowh tro,at tafe nheonta i dhr ie
uence fnm tvletpnr h kna ndyhi utt e tie,nl
boeetn instveteamtl sf r f-eetreecrtc posegratg
penmfhol td on yegefe eewrdhhenhdliilsafdsyeol ,ai
The decrypting program "getl.bas" read the
message from the file "send". The length again was
determined to be 190, and the number of shuffles needed
18. The deck had been shuffled eight times by


22
"givel.bas", so "getl.bas" continued by shuffling the
remaining ten times. With the original message
recovered, "get2.bas" displayed the decrypted character
string.
Multi-Deck Encryption
The second phase of the encryption was a more
elaborate variation of the first. Instead of
considering the entire character string as one data
deck, the character string would be divided into
smaller data decks of unequal lengths, and each data
deck would be shuffled separately. The separate decks
would then be concatenated together along with an
additional ASCII character placed at the beginning of
each deck to denote the length of the following data
deck. In other words, what began as
[character string of length n]
would be encrypted into
[flagl][data deckl][flag2][data deck2] ...
The number of data decks was a function of the original
length; longer strings were separated into more data
decks than were shorter strings. The size of each data
deck was again a function of the total length of the
character string with each data deck's length derived
as a specified proportion of the original length.
Table 2 shows the various lengths of the original
character string chosen for a particular number of data


23
decks, and the percentage of the original length being
used for the lengths of the smaller data decks.
Because the maximum string length allowed by BASIC from
the keyboard was 254, longer character strings were not
considered. Also, the breakpoints in the original
length, such as 10, 26, and 80, and the percentages
chosen were arbitrary, and could be modified within the
program if desired.
Original Length x Number of Decks Percentage breakdown
x <= 10 1 100
10< x <= 26 2 40, 60
26< X <= 80 3 30, 50, 20
80< X <= 172 4 25, 15, 40, 20
172< X <= 254 5 35, 15, 25, 20, 5
TABLE 2
DECK SIZES AS PERCENTAGE OF ORIGINAL LENGTH
In addition to the problems from the original
algorithm used for the shuffling, described in the
previous section, the biggest challenge was in dealing
with the individual decks whose length was odd. Again,
the shuffling algorithm can only deal with data decks
of even sizes. Previously, if the data deck was odd, a
blank character was added to the end of the string, and
the original deck was, for all purposes, unchanged.
However, with multiple decks from one character string,
adding a blank character was not acceptable in most
cases because the blank would be added somewhere within


24
the string. The receiving code would then, if
possible, have to detect whether or not there was a
blank at the end of the data deck, and if so, then
determine if the blank was added to ensure an even
sized deck, or if the blank was part of the original
string. A blank could still be added to the end of the
last data deck created, if needed, with no effective
change to the original string.
The problem was resolved in two steps. First,
the length of the original string was adjusted, if
needed, by adding a blank character string. This
guaranteed that the length of the original string would
be even. Next, a subroutine was written to check the
length of each data deck as the deck was being created,
with the exception of the last deck. If the length was
odd, then the length was incremented. With this
additional step, all lengths were guaranteed to be of
even lengths. The length of the last deck was derived
by substracting the total lengths of all previous
decks, which again is guaranteed to be even. The
result was a series of data decks of varying and always
even sizes.
After a data deck was shuffled, it was
concatenated with the previous data decks, and when the
entire string was encoded, the encrypted string was
saved in a file named "send". Additionally, the length
of each deck needed to be encoded and saved in the file


25
in order for the receiving code to determine how many
characters belonged in any one deck. This was done by
taking the length of the data deck, adding 33 to that
length, and finding the ASCII character relating to the
sum. 33 was used as an offset to the length to avoid
the non-printable ASCII characters. For example, if
the length of the data deck was 36, then 36 + 33 = 69,
and the ASCII character whose decimal value is 69 is
"E". This character was placed in front of the data
deck.
The final step before saving the encrypted
string was to include the number of data decks as an
ASCII character. 100 was added as an offset to the
number of data decks in the string, and the ASCII
equivalent for that value was used as a flag. The flag
was placed at the beginning of the encrypted string,
and the entire string was saved in the file "send".
The code used to generate the multi-deck
encryption in BASIC was called Hgive2.bas". The
decrypting code, Mget2.bas", began by reading the first
character from the file "send". The decimal value for
this ASCII character, less an arbitrary offset of 100,
represented the total number of data decks in the file.
This number was used as a loop counter for the
shuffling algorithm. The remaining character string


26
was copied from the file "send" to the variable INPUT.
On each pass through the algorithm, ,,get2.bas" would
perform the following:
1. Read the first character of INPUT. This
character held the encrypted information on the
length of the next data deck. The value, which
was the ASCII decimal value of the character
less an arbitrary offset of 33, was stored in
the variable LENGTH.
2. From the file "shuffle", the number of shuffles
needed for a data deck of size LENGTH was
found.
3. The next LENGTH characters were read from INPUT
and stored in the array main_2.
4. The shuffling algorithm used in "getl.bas" was
used, and the recovered deck was concatenated
onto the string "output".
When all data decks were decrypted, the string OUTPUT
containing the original character string was displayed.
See Appendix B for the listings of all BASIC
programs written, as well as an example output from
"give2.bas" and "get2.bas".


27
CHAPTER IV
APPLICATIONS IN C
Advantages
Although the shuffling algorithm written in
BASIC on the PC was functional, there were
shortcomings. Specifically, there were memory
limitations which would not allow multiple arrays with
over 400 elements. Added to this was the fact that
BASIC would allow a maximum of just 254 characters
input from the terminal for a string. There was also
the problem of the limited processing capabilities on
the PC, accounting for long shuffling times for the
larger decks with high shuffle counts.
It was decided to rewrite the code from BASIC
to C and move from the PC environment to a minicomputer
for the following reasons:
1. The ability to determine the number of shuffles
needed for data decks larger than 400.
2. The benefit of a faster machine when shuffling
the data decks.
3. The ability to use shell scripts for entering
character strings that were longer than those
accepted directly from the terminal.


28
4. The ability to use entire ASCII files of
unknown size as input.
All of the programs written in BASIC were
converted to C code and run on a SEQUENT minicomputer.
Instead of saving the number of shuffles needed in a
file, as was done in BASIC, the decksize/shuffles pairs
were stored in an INGRES data base. Although the code
conversion was more difficult than first anticipated,
it proved to be worth the effort as it accomplished all
of the goals described in the previous list.
The first step was to produce the code which
generated the number of shuffles needed for a given
size data deck. The program written was called
"cardsl.qc", and the compiled code was called "cardsl".
The same algorithm that was used for the BASIC code was
used in C. With the C code, however, the size of the
data decks was increased to 3000 characters. This
allowed for a much wider range of data deck sizes than
were possible with the PC version in BASIC.
The program "givel.qc" was the conversion of
"givel.bas" which shuffles the entire character string
as one data deck. The compiled code was called
"givel". Again, the main differences between the C
version and the BASIC version were the lengths of
character strings allowed and the use of the INGRES
data base in the C version.


Initially, the problem of reaching the maximum
number of characters in a given string arose again with
the C version. Although the code itself was capable of
handling much larger character strings, the terminal
emulator that was being used only allowed 254
characters. This was resolved by writing a shell
script for "givel" that became the standard input
rather than the keyboard. The code for the shell
script was the following:
#! /bn/sh
givel END_IN
text \
text \
END_Ilf
All text between the call to "givel" and the
flag END_IN was used as input. The input string could
now be as large as 3000, which was the largest size
data deck for which the number of shuffles needed was
known.
The decrypting code, "get2.qc", was essentially
a straightforward conversion of the "get2.bas" code on
the PC. The only notable modification made was taking
into account that BASIC arrays begin with element 1,
whereas C arrays begin with element 0. Because of this
difference, the indexing for the arrays had to be
altered.


30
Multi-Deck Encryption
Although the conversion from BASIC to C for the
single deck encryption required only minor changes, the
conversion for the multi-deck encryption code was much
more involved. The main reason for this was due to the
superior string manipulating capabilities of C. These
capabilities allowed for the program ,,give2.qc" to be
more modular than its BASIC counterpart, and allowed
the program to be easily enhanced to accommodate larger
and larger character strings.
The algorithm was essentially the same as with
"give2.bas". A character string was taken as input
and, depending on the length, separated into smaller
data decks which were then shuffled independently.
Flag characters were added to the front of each data
deck for the decrypting code to use in determining the
length of any deck. The data decks plus flags were
concatenated and stored in the file "send", which was
read by the decrypting code "get2.qc".
Breaking the given character strings into
smaller data decks was accomplished by one of two
subroutines. Subroutine "break_string" was for any
deck but the last deck, and "break_last" was for the
last deck. The difference between the two subroutines
was that while "break_string" read a specified number


of characters to make up the data deck, "break_last"
read all characters from a specified position in the
character string to the end of the string.
Having the two different subroutines made the
process of breaking the given character string into
smaller decks quite simple. For example, if the string
was to be broken into two decks, the program called
Hbreak_string" once, then "break_last" once. If the
character string was to be broken into four decks, then
"break_string" was called three times, and "break_last"
once. The program was written to break the character
string into as many as five decks, depending on the
length of the string, but it could easily be modified
to break into any number of decks by adding additional
"else if" statements, and calling "break_string" and
"break_last" the appropriate number of times.
Table 3 shows the various lengths of the
original character string chosen for a particular
number of data decks, and the percentage of the
original length being used for the lengths of the
smaller data decks. The breakpoints in the original
length, such as 20, 66, and 154, and the percentages
chosen were arbitrary, and could be modified within the
program if desired.


32
Original Length x Number of Decks Percentage breakdown
X <= 20 1 100
20< X <= 66 2 40, 60
66< X <= 154 3 30, 50, 20
154< X <= 254 4 25, 15, 40, 20
254< X 5 35, 15, 25, 20, 5
TABLE 3
DECK SIZES AS PERCENTAGE OF ORIGINAL LENGTH
The flag used to denote the length of a
particular data deck was generated in a slightly
different manner than the flag used in "give2.bas".
Because the lengths of the decks could now be longer
than before, a one-character ASCII flag was
insufficient, and a two-character ASCII flag was used
instead. The flag was a base 60 representation of the
length of the deck with an arbitrary offset of 65. The
offset needed to be.at least 33 to avoid the
non-printable ASCII characters. The flag was first
stored in a three-byte variable called ascii_flag. The
higher order byte of the flag was found by dividing the
deck size by 60:
ascii_flag[0] = toascii(decksize/60 + 65)
The second byte of the flag is the remainder in base
60:
ascii_flag[l] = toascii(decksize % 60 + 65)
The last byte, ascii_flag[2] was loaded with the null
character #\0' to mark the end of the flag.


33
For an example, suppose the size of the data
deck was 154. Then:
ascii_flag[0] = toascii(154/60 + 65)
ascii_flag[0] = toascii(67) = "C"
ascii_flag[l] = toascii(154 % 60 + 65)
ascii_flag[l] = toascii(99) = "c"
and the ASCII flag for 154 = "Cc".
Base 60 allowed for flags to be generated for
data decks with sizes up to 3600 characters.
Modifications could be made by changing the base used
for the flags, thereby making the scheme used for the
flag generation more difficult to detect.
The decrypting program "get2.qc" was a
straightforward conversion of "get2.bas". First, the
ASCII flag was decrypted to determine the size of the
following data deck, then the deck was read into an
array and decrypted using the same shuffling algorithm
as before. Finally, the data deck was concatenated to
the string "output". When all decks had been
successfully shuffled, the string "output", which held
the entire original message, was displayed.
ASCII File Encryption
The final application for the shuffling
technique was produced by "give3.qc". This program
used an ASCII text file, of any size, as input. Using
a random number generator, an even number n from 2 to


34
3000 was produced. The program then read n bytes from
the file and shuffled them as in the previous program.
By convenient coincidence, all ASCII characters are one
byte in size. The encrypted data deck, along with
ASCII flags to denote the length of the deck, were read
into a file "send". The two-byte ASCII flag was done
in the same manner as in "give2.qc", with modulo 60
arithmetic and an offset of 65. The process was
repeated until the entire input file had been read,
shuffled, and stored in "send". The decrypting code,
"get3.qc", then read from the file "send", recovered
the original file one data deck at a time, and stored
the information in a file "output".
The random() function in C produces a number
over a very large range. A number from 0 to 3000 was
generated by performing modulo arithmetic on the number
produced by random(), and stored in the variable
deck_size:
deck_size = random() % 3000;
Two conditions had to be avoided: 1) deck_size = 0,
and 2) deck_size being of odd size. The first
condition was avoided by setting deck_size to 2 if the
result of the random() function was 0. The second
condition was avoided by incrementing deck_size by 1 if
the size was odd.


35
The fread() function was used to read the bytes
of data from the input file. It also returned the
number of bytes read. All ASCII characters are read
including new-line characters. This made for
interesting "send" files, which had new-line characters
throughout the text. When the fread() read the
character '\0', which is the null or end-of-file
character, fread() returned a value of 0. The program
"give3" shuffled whatever deck was left, and closed
both files.
The only other concern was the length of the
last data deck, which may or may not be even. This was
corrected by adding a blank character to the end of the
string as was done with previous programs.
See Appendix C for the program listings of all
code generated in C for this project. As an example of
"gives", the file "give3.qc" was used as input for the
program. Included in Appendix C is the file "send",
which is the encrypted version of "give3.qc", and may
be compared to the original text, also in Appendix C.


36
CHAPTER V
INVESTIGATION OF DERIVED NUMBER PAIRS
One of the most interesting observations that
was made during this project was the relationship, or
apparent lack of relationship, between the various
number of shuffles needed for any given data deck.
Once the code was converted to C and run on a
minicomputer, the largest size data deck that was
shuffled was one of 3000 elements. Larger sizes could
be run on the same type of machine, but the time needed
for the larger shuffles prohibited checking these
larger sizes.
When all 1500 points were plotted, three linear
patterns emerged, two of which were not detectable when
only the first 200 points were plotted. The first
linear pattern, as noted earlier, was created by the
peaks of the graph. These were on the line y = x-2
where x was the size of the data deck and y was the
number of shuffles needed for recovery. The second
linear pattern was on the line y = (x-2)/2. The third
was actually a combination of the lines y = (x-4)/3 and
y = x/3, both of which plot closely together and appear
as one line with an x-axis from 0 to 3000. It is
suspected, but not verified, that if more data points


37
could be generated, other line patterns would be
detected. Figure 4 shows the graph of deck size vs.
shuffles for deck sizes from 2 to 3000.
3
2.9
2.8
2.?
2.6
2.5
2.4
2.3
2.2
2.1
2
1.9
2 a
*2 1-4
.£ 1.3
£ 1.2
1.1
1
0.9
0.0
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
0 300 600 900 1200 1500 1800 2100 2400 2700 3000
Deck Size
FIGURE 4
DECK SIZE VS. SHUFFLES
In stating that a linear pattern was
detectable, it is meant that a large enough number of
points fell on that line to make the line noticeable.
When a pattern was seen, various points making up the
pattern were used as endpoints in the slope equation,
and the equation for the line was derived from there.


38
A chart comparing the number of points that fell on the
four lines to the total number of points was created
and is shown in Figure 5.
FIGURE 5
DATA FORMING LINE PATTERNS
It is interesting to note how few deck sizes
require shuffles between the y = x-2 line and the y =
(x-2)/2. This was a pattern that could not be seen
until all of the 1500 points were plotted.
Specifically, with deck sizes larger than 500, there
appears to be only eight deck sizes that fall between
the two lines. Those points and their corresponding
shuffles are listed in Table 4.


39
Deck Size Number of Shuffles
626 500
730 486
842 812
1332 1210
1370 1332
2188 1458
2198 2028
2810 2756
TABLE 4
POINTS BETWEEN Y = X-2 and Y = (X-2)/2
The relationship between these numbers, if
there exists one, is not apparent. It was noted,
however, that two of the deck sizes, 626 and 842,
produce a prime number when divided by 2, but the
remaining do not appear to have any characteristics in
common.
Another interesting pattern emerged when
the plot of the 1500 points was expanded to show the
y-values from 0 to 200 in greater detail. Figure 6
shows the expanded graph.


Ho. of Shuffles
40
FIGURE 6
EXPANDED PLOT OF 1500 POINTS
As Figure 6 shows, there are several points
where the number of shuffles needed for recovery were
the same. Table 5 shows the five linear patterns that
were detected, the number of points that fell on each
line, and the number of factors for each y value


41
Y Value Number of Number of
Points Factors
36 48(3.2%) 9
60 55(3.6%) 12
84 28(1.9%) 12
156 26(1.7%) 12
180 33(2.2%) 15
TABLE 5
LINEARITIES IN NO. OF SHUFFLES
These five numbers have some interesting similarities.
They are all divisible by three, and the number of
factors for each number is also divisible by three.
Although no other linear patterns were detected, others
may present themselves should larger data decks be
investigated.
It was evident from Figure 6 that several deck
sizes required the same number of shuffles for
recovery. A program was written to determine how many
decks required any one particular number of shuffles.
In other words, how many decks recover in 1 shuffle, or
4 shuffles, or 50 shuffles? Also, what is the most
common number of shuffles required? From Table 5, it
appeared that 60 shuffles is the most common number,
but checking all possible shuffles would be needed to
verify this assumption. Figure 7 shows the
relationship between the number of shuffles and the
number of decks requiring a given number of shuffles.
For the benefit of clarity, only the first 1500


42
shuffles were plotted. Beyond 1500, there were either
0, 1, or 2 decks that required a given number of
shuffles.
FIGURE 7
NO. OF SHUFFLES VS. NO. OF DECKS
Figure 7 verified that 55 was the largest
number of decks requiring any one number of shuffles.
In this case, there are 55 different deck sizes that
require 60 shuffles, agreeing with the information
shown in Table 6. Figure 7 also showed that the
majority of the number of shuffles needed relate to
only one, two, or three data decks.


43
There was one nonlinear relationship found
between the size of the data decks and the number of
shuffles needed for recovery. It was found that if
no. of cards = 2n
then
no. of shuffles = n
This relationship would prove to be extremely
beneficial if there were kilobytes or megabytes of text
to be encrypted. The data decks could be set to 16,384
or 32,768 bytes in size, and the entire data deck could
then be encrypted and recovered in only 14 and 15
shuffles, respectively.


44
CHAPTER VI
CONCLUSION
This paper has shown that the data shuffling
technique can be used as an effective and simple method
of encryption. The algorithm is easily programmed in
either BASIC or C, and, particularly in C, can be
modified to increase the difficulty of unwanted
deciphering. It can be used independent of other types
of encryption, or coupled with other techniques. For
example, a key could be used with a substitution
cipher, and the resulting encrypted message could then
be used as the input to the shuffling algorithm.
There are other variations of the shuffling
technique as well. In the case of entire ASCII file
encryption, predetermined lengths could be assigned to
the data decks instead of the randomly generated
lengths. This could produce an encrypted message that
was either process intensive, if the lengths chosen
were to fall on the line y = x-2, or process moderate,
if the lengths chosen were integer powers of 2. If the
process intensive approach is taken, the intercepted
message, if the algorithm is known by the interceptor,
could take a substantial amount of computer time


45
to decipher. This may not prove to be beneficial, or
the interceptor may not have the capability to decipher
the message.
The technique of splitting the character string
into smaller data decks can easily be modified to
change the lengths of the data decks, or the number of
data decks for a given character string. The flags
denoting the lengths of the data decks can be changed
from base 60 to any other base large enough to handle
the data decks, such as base 50 or base 70. The
offsets used in the flags could be easily changed. All
of these variations could be incorporated without
changing the basic algorithm that actually shuffles the
data.
A change to the basic algorithm might be to
shuffle the data in such a way that the first and last
elements do not always remain the same. This would
involve alternating which subdeck was used to begin
reloading the main array. This variation was not
investigated, but may prove to be of interest.
All of these variations would effectively
increase the time and the resources needed for
deciphering the message, should the message be
intercepted. As with most simple cryptography schemes,
the more that is known about the method of encryption,
the easier it becomes to decipher. It is suggested
that the variation which uses the random number


46
generator to produce the lengths of the data decks
would be the best deterrent against an interceptor with
some knowledge of the algorithm. Another suggestion
would be to alternate which element of the two-element
flag represents the higher-order byte. This would help
to obscure the many lengths where the higher-order byte
represents 0. Regardless of the variation used, the
data shuffling technique for data encryption is one
that is both functional and fascinating, relying on a
simple algorithm that can be easily applied on various
host computers and in any of a number of different
programming languages.


47
REFERENCES
Katzan, Harry Jr. The Standard Encryption Algorithm.
New York: Petrocelli, 1977
Admillo, Richard A., David, P. Dobkin, Anita K. Jones,
Richard J. Lipton, eds. Foundations of Secure
Computation. New York: Academic Press, 1978


1
6
11
16
21
26
31
36
41
46
51
1
29
6
34
11
39
16
44
21
49
26
1
15
29
43
6
20
34
48
11
25
39
48
APPENDIX A
Shuffling 52 Cards
Shuffle = 0 (Initial State)
2 3 4 5
7 8 9 10
12 13 14 15
17 18 19 20
22 23 24 25
27 28 29 30
32 33 34 35
37 38 39 40
42 43 44 45
47 48 49 50
52
Shuffle = 1
27 2 28 3
4 30 5 31
32 7 33 8
9 35 10 36
37 12 38 13
14 ' 40 15 41
42 17 43 18
19 45 20 46
47 22 48 23
24 50 25 51
52
Shuffle = 2
14 27 40 2
28 41 3 16
42 4 17 30
5 18 31 44
19 32 45 7
33 46 8 21
47 9 22 35
10 23 36 49
24 37 50 12
38 51 13 26
52


49
Shuffle = 3
1 33 14 46 27
8 40 21 2 34
15 47 28 9 41
22 3 35 16 48
29 10 42 23 4
36 17 49 30 11
43 24 5 37 18
50 31 12 44 25
6 38 19 51 32
13 45 26 7 39
20 52
Shuffle = 4
1 17 33 49 14
30 46 11 27 43
8 24 40 5 21
37 2 18 34 50
15 31 47 12 28
44 9 25 41 6
22 38 3 19 35
51 16 32 48 13
29 45 10 26 42
7 23 39 4 20
36 52
Shuffle = 5
1 9 17 25 33
41 49 6 14 22
30 38 46 3 11
19 27 35 43 51
8 16 24 32 40
48 5 13 21 29
37 45 2 10 18
26 34 42 50 7
15 23 31 39 47
4 12 20 28 36
44 52
Shuffle = 6
1 5 9 13 17
21 25 29 33 37
41 45 49 2 6
10 14 18 22 26
30 34 38 42 46
50 3 7 11 15
19 23 27 31 35
39 43 47 51 4
8 12 16 20 24
28 32 36 40 44


o
in
CTl cn CTl CTi 03 00 00 CD
oiHoin^coHMn't
oinoinoinoino
inHHNNno^^in
[ C IDIOIDVO

1^
00
II
in in in in ^ ^ ^
<1) inHNn^^HNn II
(V
mcomconcomco
ncoHHNMnn^^
t-i
3
Xi
co
1-1
1-1
3
JC
CO
cm n n n n cm cm cm cm cm cMr^cMt^cMrvCMi^cM
in nHMMM'lNHCMnM'in CMt^HHCMCMCOn^^in
HrHHrHrHOOOOO
HrHCMCOTj'inrHnjfn^'in
00
HlDrllOHDrllOrl
HDHHNOJnnM'M'in


51
APPENDIX B
BASIC PROGRAM LISTINGS
10 REH *****************************************************
20 HEM * cards.bas *
30 SEN * First try at shuffling algorithm. Accepts input *
* from terminal for *
40 REH * data decks of size 2 to 400 (even sizes only). *
* Calculates and *
50 REH * returns the number of shuffles needed for given *
* data deck. *
60 REH *****************************************************
70 DIH A [ 4 0 0 ], B [ 2 0 0 ], C[200 ], D[ 400 ]
80 PASS = 1
90 INPUT "Enter number of cards (1 to Quit) --> ", CARDS
100 IF CARDS = 1 THEN KEY ON:END
110 IF CARDS > 400 THEN PRINT "Too many cards to shuffle .. ":G0T0
90
120 IF INT(CARDS/2) <> CARDS/2 THEN PRINT "Deck size must be even
..":GOTO 90
130 REH **** Show the deck for each shuffle if size = 52 ****
140 IF CARDS = 52 THEN SHOW = 1
150 REH Load the two initial arrays. A holds original order ****
160 REH **** D holds deck to be shuffled ****
170 FOR I = 1 TO CARDS
180 A[I ] = I
190 D[I] = I
200 NEXT I
210 REH **** Split deck D into two equal arrays, B and C ****
220 FOR I = 1 TO CARDS/2
230 B[I] = D[I]
240 C[I] = D[I+CARDS/2]
250 NEXT I
260 REH Shuffle the two smaller arrays back into array D ****
270 REH such that d[1] = b[l], d[2 ] = c[l], d[3 ] =b[2 ],
* d[4]=c[2], etc *
280 FOR I = 1 TO CARDS/2
290 D[2*1-1] = B[I]
300 D[2*1 ] = C[I ]
310 NEXT I
320 REH *** SHOW = 1 if decksize = 52? sub 440 is the printout
* routine ***
330 IF SHOW = 1 THEN GOSOB 440
340 FAIL = 0
350 REH *** Compare A[i] to D[i] for each ith element? if not


52
* the sane, ***
360 REH *** continue with the shuffling. ***
370 FOR I = 1 TO CARDS
380 IF A[I ] <> D[I ] THEN FAIL = l:GOTO 400
390 NEXT I
400 IF FAIL = 1 THEN PASS = PASS + 1: GOTO 220
410 PRINT OSING "Success on shuffle ###"; PASS
420 GOTO 80
430 END
440 LPRINT OSING "Pass = tt ";PASS
450 FOR I = 1 TO 50 STEP 5
460 LPRINT D[I]; D[1 + 1],D[1 + 2],D[1 + 3 ], D[1 + 4 ]
470 NEXT I
480 LPRINT D[51], D[52]:LPRINT:LPRINT
490 SHOW = 0
500 RETURN
10 REH *******************************************************
20 REN * cards2.bas *
30 REH cards2.bas generates the number of shuffles needed *
* for data decks *
40 REH of size 2 to 400, and store the number pairs in file*
* "shuffle *
50 REH *******************************************************
60 KEY OFF
70 DEFINT A^Z
80 OPEN "a", 1, "SHOFFLE"
90 DIH A[400],B[200], C[200], D[400]
100 FOR LOOP = 1 TO 200
110 CARDS = LOOP*2
120 PASS = 1
130 REH ** Load the initial arrays. **
140 REH ** and D[i] will be the shuffled array **
150 FOR I = 1 TO CARDS
160 A[I ] = I
170 D[I] = I
180 NEXT I
190 REH ** Split array D in half **
200 FOR I = 1 TO CARDS/2
210 B[I] = D[I]
220 C[Ij = D[I+CARDS/2]
230 NEXT I
240 REH ** Shuffle the smaller arrays back into array D **
250 FOR I = 1 TO CARDS/2
260 D[2*1-1 ] = B[I ]
270 D[2*1] = C[I ]
280 NEXT I
290 FAIL = 0
300 REH Check a[i] = d[i] for all i. If unequal, reshuffle *
310 FOR I = 1 TO CARDS
320 IF A[I] <> D[I] THEN FAIL = 1:GOTO 340
330 NEXT I
340 IF FAIL = 1 THEN PASS = PASS + 1: GOTO 200


53
350 HEX *If arrays are equal, save the number pairs and print*
360 PRINTJl, CARDS;",";PASS
370 PRINT USING "No. of cards = Hi, No. of shuffles = iff
";CARDS, PASS
380 NEXT LOOP
390 END
400 LPRINT OSING "Pass = li "?PASS
410 FOR I = 1 TO 50 STEP 5
420 LPRINT D[I], D[1 + 1 ] ,D[1 + 2],D[1 + 3], D[1 + 4]
430 NEXT I
440 LPRINT D[51], D[52]:LPRINT:LPRINT
450 RETURN
10 REH ********************************************************
20 REN . GIVEl.bas *
30 REN Part 1 of encryption. This code will take the given*
* string, and *
40 REH determine bow many shuffles is needed for the entire*
* string to be *
50 REH * encrypted at one tine, shuffle the string 1-half the*
* needed times, and *
60 REH * save the encrypted string to a file called "SEND". *
* The program *
70 REH * uses a file called "SHUFFLE" which holds the *
* information on how *
80 REH * many shuffles are needed for a given string length. *
* Only even *
90 REH * length strings can be used. If the string is of odd*
* length, a *
100 REH blank space is added at the end of the string. *
110 REH *******************************************************
120 CLS
130 DEFINT L, P, E
140 DEFSTR B-D
150 DIH B[127 ],C[127],D[ 254 ]
160 PRINT "Enter String:":PRINT
170 LINE INPUT ", TEXT$
180 LENGTH = LEN(TEXT$)
190 PRINT:PRINT "The length of the string is"; LENGTH
200 IF INT(LENGTH/2) <> LENGTH/2 THEN TEXT? = TEXT? + ":PRINT
"Text increased to ";LEN(TEXT?)
210 OPEN "I", #1, "SHUFFLE"
220 IF EOF(1) THEN PRINT "Too many characters to encrypt.":END
230 INPUT #1, CARDS*, PASS
240 IF CARDS* = LEN(TEXT?) THEN CLOSE #l:GOTO 250 ELSE GOTO 220
250 PRINT USING "string of length tii will take ttl shuffles";
CARDS*, PASS
260 REH
270 REH load the initial arrays with individual characters
280 REH


54
290 FOR I = 1 TO CARDS!
300 D[I] = LEFT?(TEXT$,1)
310 TEXT? = RIGHT?(TEXT?/LEN{TEXT?) 1)
320 NEXT I
330 REH
340 REH Shuffle the arrays (1-half) to recovery. If PASS is
odd, then shuffle
350 REH to (PASS-1)/2, else shuffle to (PASS/2)-1. If CARDI -
PASS = 2, then
360 REH the data deck is inverted completely, and can be read
backwards,
370 REH which is avoided by not shuffling completely to the
halfway point
380 REH
390 IF INT(PASS/2) <> PASS/2 THEN EHD1 = (PASS l)/2 ELSE END1 =
(PASS/2) 1
400 FOR J = 1 TO END1
410 REH
420 REH Split the array in half for shuffling.
430 REH
440 FOR I = 1 TO CARDS!/2
450 B[I] = D[I]
460 C[I] = D[I + CARDS!/2]
470 HEXT I
480 REH
490 REH shuffle the two arrays
500 REH
510 FOR I = 1 TO CARDS!/2
520 D[2*1-1 ] = B[I]
530 D[2* I] = C(I]
540 NEXT I
550 NEXT J
560 REH
570 REH Put the encrypted string back together and display
580 REH
590 FOR I = 1 TO CARDS!
600 SEND? = SEND$ + D[I]
610 NEXT I
620 PRINT:PRINT "The encrypted code is:"
630 PRINT:PRINT SEND$
640 REH
650 REH send to a file to be read by the receiving code.
Surrounding the
660 REH string with quotes assures the entire text will be sent to
"GET1"
670 REH
680 SEND? = CHR?(34)+SEND$+CHR$(34)
690 OPEN "0", #2 "SEND"
700 PRINTj 2 SEND?
710 CLOSE \2
10 REH ********************************************************


20 SEN * GETl.bas *
30 REM * Part 2 of the encryption. This programs takes the *
* string located *
40 REM * in "SEND", determines the length of the string, and *
* how many *
50 REM * shuffles needed for recovery. The string is loaded *
* into the arrays *
60 REM and the rest of the shuffling is done. The recovered*
* string is *
70 REM then displayed. *
80 REM ********************************************************
90 CLS
100 DEFIMT L,P,S
110 DEFSTR B-D
120 DIM B[127],C[127], D[254]
130 PASS = 1
140 OPEN In, #2, "SEND"
150 INPOT f2, SEND$
160 CLOSE 12
170 PRINT "The encrypted string is:
180 PRINT:PRINT SEND$
190 LENGTH = LEN(SEND$)
200 IF INT(LENGTH/2) <> LENGTH/2 THEN LENGTH = LENGTH + 1:SEND$
SEND$ + "
210 REM
220 REM Find out the number of shuffles necessary for recovery
230 REM
240 OPEN "I",#l, "SHUFFLE"
250 INPUT #1, CARDS!,PASS
260 IF CARDS* = LENGTH THEN CLOSE /I ELSE GOTO 250
270 PRINT
280 PRINT USING "String of length Hi will take Hi
Shuffles.";CARDSI,PASS
290 REM
300 REM load the arrays
310 REM
320 FOR I = 1 TO CARDS*
330 D[I] = LEFT?(SEND$,1)
340 SEND$ = RIGHT?(SEND$, LEN(SEND?) 1)
350 NEXT I
360 REM
370 REM Shuffle the array to recovery. If PASS is odd, then
the program
380 REM "givel" will have shuffled (P-1)/2 times, and START
must be
390 REM (P-l)/2 + 1. If PASS is even, then START must be (P/2
1), where
400 REM P is the number of shuffles needed.
410 REM
420 IF INT(PASS/2) <> PASS/2 THEN START = (PASS l)/2 + 1 ELSE
START = PASS/2
430 FOR J = START TO PASS
440 REM
450 REM Split the array in half for shuffling.


460 REH
470 FOR I = 1 TO CARDS!/2
480 B[I] = D[I ]
490 C[I] = D[I + CARDS!/2 ]
500 NEXT I
510 REH
520 REH Shuffle the two arrays
530 REH
540 FOR I = 1 TO CARDS!/2
550 D[2 I 1] = B[I ]
560 D[2 I ] = C[I]
570 HEXT I
580 NEXT J
590 REH
600 REH Put the string back together and display
610 REH
620 FOR I = 1 TO CARDS!
630 GOT$ = GOT$ + D[I]
640 NEXT I
650 PRINT:PRINT "The recovered string is:"
660 PRINT:PRINT GOT$
10 REH *********************************************************
20 REH * GIVE2.BAS *
30 REH Second phase of the encryption. Take the given string,*
* and *
40 REH depending on the length, separate the string into *
* smaller data *
50 REH decks, each of which is then shuffled independently. *
* Flag *
60 REH characters are added to the front of each data deck *
* for the *
70 REH receiving code to use to determine how many characters*
* are in *
80 REH each deck. The data decks plus flags ar.e concatenated*
* and *
90 REH stored in file "SEND", to be Used by "GET2.basn for *
* recovery. *
100 REH ********************************************************
110 CLS:KEY OFF
120 DEFINT A, I,J,L, T :DEFSTR B,C,D, S
130 DIH B[50 ], C[50], D[100]
140 PRINT "Enter string (254 character limit):PRINT
150 LINE INPUT "", TEXT$
160 LENGTH = LEN(TEXT$)
170 IF INT(LENGTH/2) <> LENGTH/2 THEN LENGTH = LENGTH + 1:TEXT$
T E X T $ + "
180 CLS
190 PRINT USING "Total data deck is of size ttt;LENGTH:PRINT
200 REH
210 REH Determine how many data decks for the given string


57
220 HEN
230 IF LEHGTH <= 10 THEN L[1 ] = LENGTH:S[1 ] = TEXT?:LOOP = 1
240 IF (10 < LENGTH) AND (LENGTH <= 26) THEN GOSDB 330
250 IF (26CLENGTH) AND (LENGTH <= 80) THEN GOSDB 390
260 IF (80CLENGTH) AND (LENGTH<= 172) THEN GOSUB 460
270 IF LENGTH > 172 THEN GOSDB 550
280 REN
290 REH *** Shuffle each data deck individually ***
300 GOSDB 680
310 SIT$ = INKEY?:IF SIT$ = THEN 310
320 END
330 REH **** two data decks ****
340 L[ 1] = CINT(LENGTH *.4):T = 1:GOSDB 660
350 L[2] = LENGTH L[1 ]
360 S[1] = LEFT$(TEXT$,L[1]):S[2] = RIGHT?(TEXT?, L[2 ])
370 LOOP = 2
380 RETDRN
390 REH ***** three data decks ****
400 L[1] = CINT(LENGTH .3):T=1:GOSDB 660
410 L [ 2] = CINT(LENGTH .5):T = 2:GOSDB 660
420 L[ 3] = LENGTH (L[1 ] + L [ 2 ])
430 S[1] = LEFT?(TEXT?,L[1]):S[2] =
HID?(TEXT$,L[1]+1,L[2]):S[3]=RIGHT?(TEXT?,L[3])
440 LOOP = 3
450 RETDRN
460 REH ***** FOOR DATA decks ******
470 L[1] = CINT(LENGTH *.25):T = 1:GOSUB 660
480 L[2] = CINT(LENGTH 15):T = 2:GOSOB 660
490 L[3] = CINT(LENGTH .4):T = 3:GOSDB 660
500 L[4 ] = LENGTH (L[1 ] + L[2] + L[3])
510 S[l] = LEFT$(TEXT$,L[1]):S[2] = HID$(TEXT?,L[1]+1,L[2])
520 S[3] = HID?(TEXT$,L[1]+L[2]+1,L[3]):S[4] = RIGHT?(TEXT$ L[4])
530 LOOP = 4
540 RETDRN
550 REH ***** FIVE DATA decks ******
560 L[1] = CINT(LENGTH * .35):T = 1:GOSUB 660
570 L[2] = CINT(LENGTH * .15):T = 2:GOSDB 660
580 L[3] = CINT(LENGTH * .25):T = 3:GOSUB 660
590 L[4] = CINT(LENGTH * .2) :T = 4:GOSDB 660
600 L[5] = LENGTH (L[l] + L[2] + L[3] + L[4])
610 S[1 ] = LEFT$(TEXT?,L[1]):S[2] = HID?(TEXT?,L[1]+1,L[2])
620 S[3] = HID$(TEXT$,L[1]+L[2]+1,L[3]):S[4] =
HID?(TEXT$,L[1]+L[2]+L[3]+1,L[4])
630 S[5 ] = RIGHT?(TEXT?,L[5])
640 LOOP = 5
650 RETDRN
660 IF INT(L[T]/2) <> L[T]/2 THEN L[T] = L[T] + 1
670 RETDRN
680 REH
******************************************************************
690 REH LOOP determines how many data decks must be shuffled. *
* SEND$ *
700 REH will be used to put together a string to be send to the*
* file *


58
710 SEH * and will consist of flags for the number and size of *
* the data *
720 SEH * decks, and the deck itself. All flags and decks will *
* be *
730 SEH * contatenated into SEND$ *
740 SEH ********************************************************* 750 FOB A = 1 TO LOOP
760 OPEN "I", #1, "SHUFFLE"
770 SEH *** get the number of shuffles needed for the data deck
780 IF EOF(1) THEN PSINT "Too many characters in data deck":END
790 INPOT #1,CABDSI, PASS
800 IF CABDSI <> L[A] THEN GOTO 780 ELSE CLOSE #1
810 PSINT USING "Data Deck of size ttt reguires tit
shuffles";L[A], PASS
820 FOB I = 1 TO L[A]
830 SEH
840 SEH *** Load the initial array with the individual characters
***
850 SEH
860 D[ I ] = LEFT$ (S [ A], 1)
870 S[A] = BIGHT$(S[A],LEN(S[A]) 1)
880 NEXT I
890 SEH Shuffle the arrays (1-half) to recovery. If PASS is
odd, then
900 SEH shuffle to (PASS-1)/2, else shuffle to (PASS/2)-1. If
the length
910 SEH of the string PASS+2, then the data deck is completely
inverted,
920 SEH and can be read backwards, which is avoided by not
shuffling
930 SEH completely to the halfway point.
940 SEH
950 IF INT(PASS/2) <> PASS/2 THEN END1 = (PASS l)/2 ELSE END1 =
(PASS/2) -1
960 FOE J = 1 TO END1
970 SEH *** Split the deck in half for shuffling
980 FOB I = 1 TO CABDSI/2
990 B[I] = D[I ]: C[I ] = D[I + CAEDSl/2]
1000 NEXT I
1010 SEH *** Shuffle the two halfs ***
1020 FOB I = 1 TO CABDSI/2
1030 D[2*1-1 ] = B[I]:D[2*I ] = C[I]
1040 NEXT I
1050 NEXT J
1060 SEH
1070 SEH Put the encrypted string back together, including the
length of
1080 SEH the data deck as a flag in front of each deck. The
length will be
1090 SEH converted to it's character equivalent using CHB$, and
read by the
1100 SEH receiving code and converted to it's ASCII equivalent to
recover
1110 SEH size of the data deck.


59
1120 SEH
1130 FLAG$ = CHR$(L[A ] +33 )
1140 SENDS = SENDS + FLAGS
1150 FOR I = 1 TO CARDS!
1160 SEND? = SENDS + D [ I ]
1170 NEXT I
1180 PRINT SENDS:PRINT
1190 REH *** Continue for all data decks
1200 NEXT A
1210 REH *** the first character of SENDS will contain the number
of
1220 REH *** data decks in the string, which is in LOOP
1230 DECKNO$ = CHR$(LOOP + 100)
1240 PRINT USING "The number of data decks is ##/";LOOP
1250 SENDS = DECKNOS + SENDS:PRINT SENDS
1260 REH *** Save the encrypted string to file "SEND"
1270 SENDS CHR$(3 4) +SEND$ + CHR$(34)
1280 OPEN "0", i2, "SEND"
1290 PRINT #2, SENDS
1300 CLOSE f2
1310 RETORN
10 REH *****************************"***44******i**44*****4*44**4
20 REH * GET2.bas *
30 REH * Receiving code for the second phase of the encryption.*
* Read the *
40 REH * data string stored in file SEND, which will include *
* the data deck *
50 REH * flags and the data decks. The flag is ASCII 33, and*
* holds the *
60 REH * length of the data deck to be recovered. The file *
* SHUFFLE holds *
70 REH * the information on the number of shuffles needed for a*
* given *
80 REH * deck. *
90 REH *********************************************************
100 DEFSTR B,C,D,S:DEFINT A,F,I,J,L,P,T
110 DIH B[50],C[50],D[100]
120 CLS:KEY OFF
130 OPEN "I", #1, "SEND"
140 INPUT# 1, SEND: CLOSE #1
150 PRINT "The encrypted string is:":PRINT
160 PRINT SEND:PRINT
170 REH The first character holds the number of data decks in
the string
180 LOOP = ASC(SEND)-100
190 SEND = RIGHT$(SEND,LEN(SEND) 1)
200 FOR A = 1 TO LOOP
210 REH Determine the size of the data deck, and load the deck
into


60
220 REH the array for shuffling
230 FLAG = ASC(SEND)-33: SEND = RIGHTS(SEND,LEN(SEND) 1)
240 REH Find the number of shuffles needed for data deck of size
FLAG
250 OPEN "In;#2, "SHUFFLE"
260 INPUT 12, CARDS*, PASS
270 IF CARDS* = FLAG THEN CLOSE t2 ELSE GOTO 260
280 PRINT USING "The size of deck # is fi A, FLAG
290 PRINT USING "Deck of size ft requires ftt shuffles.";FLAG,PASS
300 PRINT
310 REH Load the initial array with the data deck
320 FOR I = 1 TO FLAG
330 D[I] = L E F T $(SEND,1)
340 SEND = RIGHTS(SEND, LEN(SEND) 1)
350 NEXT I
360 REH Shuffle the array to recovery. If PASS is odd, then the
program
370 REH "GIVE2" will have shuffled (p-l)/2 times, and START must
be
380 REH (p 1)/2 + 1. If PASS is even, then START must be (p/2
+1), where
390 REH p is the number of shuffles needed.
400 IF INT(PASS/2) <> PASS/2 THEN START* = (PASS -1)/2 + 1 ELSE
START* = PASS/2
410 FOR J = START* TO PASS
420 REH Split the array in half for shuffling
430 FOR I = 1 TO FLAG/2
440 B[I] = D[I ] : C[I ] = D[I + FLAG/2]
450 NEXT I
460 REH Shuffle the two arrays
470 FOR I = 1 TO FLAG/2
480 D[2 I 1] = B[I]:D[2*1 ] = C[I]
490 NEXT I
500 NEXT J
510 REH put the string back together and concatenate with other
decks
520 FOR I = 1 TO FLAG
530 G0T$ = G0T$ + D[I]
540 NEXT I
550 NEXT A
560 PRINT "The recovered string is:":PRINT
570 PRINT GOT$
580 END
The following is an example output of "give2.bas" and "get2.bas":
Ok
load "give2
Ok
run
Enter string (254 character limit):


61
He trained bard, but it seemed that every tine we were beginning
to form into teams, we would be reorganized. I was to learn later
in life that we meet any new situation by reorganizing, producing
the illusion of progress
Total data deck is of size 222
Data Deck of size 78 reguires 30 shuffles
oWdumee g rrtty i oebe menmtai regotn etirir h dewetni,satenoe tev
b iad h wnf
Data Deck of size 34 requires 10 shuffles
oWdumee g rrtty i oebe menmtai regotn etirir h dewetni,satenoe tev
b iad h wnf Ct dzngore lo w,me .eiare bduwe sal
Data Deck of size 56 requires 20 shuffles
oWdumee g rrtty i oebe menmtai regotn etirir h dewetni,satenoe tev
b iad h wnf Ct dzngore lo w,me .eiare bduwe salY etualms iwe
eaywl arieilnewtrt aatatnfete o nsthni
Data Deck of size 44 requires 14 shuffles
oWdumee g rrtty i oebe menmtai regotn etirir h dewetni,satenoe tev
b iad h wnf Ct dzngore lo w,me .eiare bduwe salY etualms iwe
eaywl arieilnewtrt aatatnfete o nsthniHoniul h ncdr giiare bn
oslietgiuop,nzngory o
Data Deck of size 10 requires 6 shuffles
oWdumee g rrtty i oebe menmtai regotn etirir h dewetni,satenoe tev
b iad h wnf Ct dzngore lo w,me .eiare bduwe salY etualms iwe
eaywl arieilnewtrt aatatnfete o nsthniHoniul h ncdr giiare bn
oslietgiuop,nzngory o+fegr srops
The number of data decks is 5
ioWdumee g rrtty i oebe menmtai regotn etirir h dewetni,satenoe
tev b iad h wnf Ct dzngore lo w,me .eiare bduwe salY etualms iwe
eaywl arieilnewtrt aatatnfete o nsthniHoniul h ncdr giiare bn
oslietgiuop,nzngory o+fegr srops
Ok
load "get2
Ok
run
The encrypted string is:
ioWdumee g rrtty i oebe menmtai regotn etirir h dewetni,satenoe
tev b iad h wnf Ct dzngore lo w,me .eiare bduwe salY etualms iwe
eaywl arieilnewtrt aatatnfete o nsthniHoniul h ncdr giiare bn
oslietgiuop,nzngory o+fegr srops
The size of deck 1 is 78 ..
Deck of size 78 requires 30 shuffles.
The size of deck 2 is 34 ..
Deck of size 34 requires 10 shuffles.
The size of deck 3 is 56 ..


62
Deck of size 56 requires 20 shuffles.
The size of deck 4 is 44 .. Deck of size 44 requires 14 shuffles.
The size of deck 5 is 10 .. Deck of size 10 requires 6 The recovered string is: shuffles.
He trained hard, but it seemed that every time we were beginning
to form into teams, we would in life that we meet any new the illusion of progress Ok be reorganized. I was to learn later situation by reorganizing, producing


63
APPENDIX C
C PROGRAM LISTINGS
/* cardsl.qc
* finds the nuaber of shuffles needed to return the data deck
* back to the original order, and saves the card/shuffle pair in
* a data base table called SHOFFLE in the THESIS data base
*/
^include
nain()
(
/* Need the largest data decks possible */
int deck_a[3000]?
int deck_b[ 3000/2];
int deck_c[3000/2];
int deck_d[ 3000 ];
int j;
int i;
int cards;
int pass;
int fail;
/*
* Open the THESIS data base
*/
tf ingres thesis
for (j=l;j<=3000/2?j++) {
cards = j 2;
pass = 1;
/*
* Load the two initial arrays
*/
for (i = l;i <=cards;i++) {
deck_a[i] = i;
deck_d[ij = i;
}
/*
* Shuffle deck d until the orginal order is regained
*/
fr(;;) {
/*
* Split deck_d in half and load each half into deck_b and deck_c


64
*/
fail = 0;
for (i=l;i<=cards/2;i++) {
deck_b[i] = deck_d[i];
deck c[i] = deck_d[i + cards/2];
}
/*
* Shuffle the two smaller decks back into deck_d
*/
for (i = l;i<=cards/2;i++) {
deck_d[2*i-l] = deck_b[i];
deck d[2*i] = deck_c[ij;
}
/*
* Compare the cards to the original order in deck_a
*/
for (i = l;i<=cards;i++) {
if (deck_a[i] != deck_d[i]) {
pass++;
fail = 1;
break; /* Need to continue shuffling */
}
}
if (fail == 1) {
continue;
}
else {
break;
}
} /* end of FOR FAIL Loop */
/*
* Once the original order has been regained, display the number
* of passes needed for the given number of cards. Later, these
* numbers will be saved in the data base
*/
printf(" No. of cards = Id No. of shuffles =ld\n",
cards,pass);
/*
* Save the cards/pass pair in the SHUFFLE table
*/
ft append to shuffle (no.cards = cards, no_shuffles = pass)
/*
* Increment the number of cards by two, and repeat the shuffling
*/
} /*end of outer loop */
ft exit
exit(1);
)


65
/*
* givel.qc
* givel.qc will take a character string input from the terminal,
* determine it's length, find the number of shuffles necessary to
* return the string to the original state, and shuffle the string
* half-1 the number of necessary shuffles. The number of
* shuffles needed is in the THESIS data base, in the SHUFFLES
* table. The encrypted string will be saved in a
* file named SEND, to be read by the receiving program "getl.qc".
*/
{include
FILE *ff;
main()
{
char input_str[1498]?
char deck_a[1500];
char deck_b[ 1500/2 ];
char deck_c[1500/2]?
it int length;
{{ int card_cnt;
it int shuffle_cnt;
int i;
int j;
int endl;
if ((ff = fopen("send", "w")) == NULL) {
printf ("Error opening file\nB);
exit();
}
printf("Input string:\n");
fgets(input_str,1498,stdin)?
length = strlenjinput_str);
printf("\nThe length of string is $d\n",length);
/*.
* Find the number of shuffles needed for this length of text. If
* the length is odd, then add a blank space at the end.
*/
if (length I 2 == 1) {
strcat(input_str, ");
length = strlen(input_str);
printf(nNew length is ld\n", length);
)
ti ingres thesis
fi range of s is shuffle
It retrieve (card_cnt = s.no_cards, shuffle_cnt = s.no_shuffles)
II where
## s.no_cards = length


66
printf("Length id will take id shuffles to recoverin'1,
card cnt,shuffle_cnt);
/*
* Shuffle the arrays (1-half) to recovery. If shuffle_cnt is
* odd, then shuffle to (shuffle_cnt-l)/2, else shuffle to
* (shuffle/2 -1). If card_cnt shuffle.cnt = 2, then the data
* deck is inverted completely, and can be read backwards, which
* is avoided by not shuffling completely to the halfway point.
*/
if (shuffle_cnt i 2 == 1) { /* shuffle_cnt is odd */
endl = (shuffle cnt -1)/2;
}
else { /* shuffle.cnt is even */
endl = (shuffle_cnt/2) 1;
}
for (j = 1;j<=endl?j++) {
/* Split the array in half for shuffling */
for (i = 0?i<=card_cnt/2-l?i++) {
deck_b[i] = input_str[i];
deck_c[i] = input_str[i + card_cnt/2];
)
/* Shuffle the two arrays back into input_str */
for (i = 0;i <= card_cnt/2-l;i++) {
input_str[2*i] = deck_b[i ];
input.str[2*i + l ] = deck_c[ij?
}
}
/* The encrypted string is in input_str. Display and save to a
file */
printf("\nThe Encrypted string is:\nis\n",input_str);
length = strlen(input_str);
printf("The length = ld\n",length);
fprintf(ff,Bis\nn,input_str);
It exit
fclose(ff);
ex it(l);
}


67
/*
* getl.qc
* getl.qc will take a character string from the file "send",
* which has been shuffled approximately half-way to recovery,
* determine it's length, find the number of shuffles necessary to
* return the string to the original state, and shuffle the string
* to recovery. The number of shuffles needed is in the THESIS
* data base, in the SHUFFLES table.
*/
^include
FILE *ff;
main()
{
char input_str[1498];
char deck_a[ 1500 ];
char deck_b[1500/2];
char deck_c[1500/2];
If int length;
ft int card_cnt;
It int shuffle_cnt;
int i;
int j;
int start;
if ((f f = fopen("send", "r")) == HULL) {
printf ("Error opening file\n");
exit();
}
fgets(input_str, sizeof(input_str), ff);
f close(ff);
length = strlen(input_str)-l?
printf(n\nThe Encrypted string is:\nls\n",input_str);
printf(HThe length = ld\n",length)?
II ingres thesis
II range of s is shuffle
It retrieve (card_cnt = s.no_cards, shuffle_cnt = s.no_shuffles)
ft where
If s.no^cards = length
printf("Length Id will take Id shuffles to recover.\n",
card cnt,shuffle cnt);
/*
* Shuffle the arrays to recovery. If shuffle_cnt is odd, then
* "givel" shuffled (shuffle_cnt-l)/2 times, and "start" must be
* (shuffle_cnt-l)/2 +1. If shuffle_cnt is even, then "start" must
* be (shuffle cnt/2) + 1.
*/
if (shuffle_cnt I 2 == 1) { /* shuffle_cnt is odd */


start = (shuffle cnt -1)/2 + 1;
}
else { /* shuffle_cnt is even */
start = (shuffle cnt/2) +1;
}
for (j = 1;j< = start;j + + ){
/* Split the array in half for shuffling */
for (i = 0;i<=card_cnt/2-l;i++) {
deck_b[i] = input_str[i];
deck_c[ij = input_str[i + card cnt/2];
}
/* Shuffle the two arrays back into input.str */
for (i = 0;i <= card_cnt/2-l;i++) {
input_str[2*i] = deck_b[i];
input_str[2*i+l] = deck c[i]?
}
}
/* The encrypted string is in input.str. Display */
printf(nThe recovered string is:\nls\n",input_str)?
It exit
exit(1);
)


69
/* give2.qc
.* give2 will take the given string (up to 254 characters), and
* depending on the length, separate the string into smaller data
* decks, each of which is then shuffled independently. Flag
* characters are added to the front of each data deck for the
* receiving code to use to determine how many characters are in
* each deck. The data_decks plus flags are concatenated
* and stored in file "send", to be used by "get2" for recovery.
*/
{include
{include
FILE *ff?
{{ int length;
int loop_cnt;
int deckl.size;
int deck2_size;
int loop_cnt;
int odd_len_chk;
int i;
int offset?
char input_str[2998]?
char output_str[2998 ];
char data_deck[500];
char deck2[ 500 ] ?
char msg[80] ?
main()
{
{{ ingres thesis
{{ range of s is shuffle
if ((ff = fopen("send", "w")) == NOLL) {
printf ("Error opening file\n")?
exit();
)
sprintf(msg,"clearn) ?
system(msg)?
printf("Input string:\n");
fgets(input_str,2998 ,stdin);
length = strlen(input_str);
length--? /* Do not count newline char as part of string */
printf("\nThe length of string is ld\nn,length);
/*
* Find the number of shuffles needed for this length of text. If
* the length is odd, then add a blank space at the end.
*/
if (length I 2 == 1) (
input_str[length] = '
input_str[length + 1 ] = '\n';


length++;
printf("New length is td\n", length);
}
printf("The string to be encrypted is ls\n",input_str);
find_deck_no();
/* Write the shuffled string to file "send" */
fprintf(ff,"is\n",output_str);
fclose(ff);
H exit
exit(l) ?
}
static
find deck no()
{
if (length <= 20) {
printf("String will be taken as ONE deck\n");
shuffle deck(input_str,length);
)
else if (20 < length SS.length <= 66 ) {
printf("String will be TWO decks.\n");
offset = 0;
break_string(0.4)?
break 1 ast();
}
else if (66 < length &6 length <= 154) {
printf("String will be THREE decks.\nn);
offset = 0;
break_string(0.3)?
break_string(0.5);
break last();
}
else if (154 < length && length <= 254) {
printf("String will be FOOR decks.\n");
offset = 0?
break_string(0.25);
break_string(0.15);
break_string(0.4);
break last() ;
}
else if (length > 254 ) {
printf("String will be FIVE decks.\n");
offset = 0;
break_string(0.35);
break_string(0.15);
break_string(0.25);
break_string(0.2);
break_last();
static


71
shuffle_deck(deck,decksize)
char deck[254];
a { ti int decksize;
int card_cnt;
u int shuffle_cnt;
int endl;
int j;
char deck_b[ 1500/2 ];
char deck_c[1500/2];
char asci i_flag[3 ];
/* Find the number of shuffles needed for this length of text.*/
it retrieve (card_cnt = s.no_cards, shuffle_cnt = s.no_shuffles)
where
tt s.no_cards = decksize
printf("Length Id will take Id shuffles to recover.\n",
card cnt,shuffle cnt);
/*
* Shuffle the arrays (1-half) to recovery. If shuffle_cnt is
* odd, then shuffle to (shuffle_cnt-l)/2, else shuffle to
* (shuffle/2 -1). If card_cnt shuffle_cnt = 2, then the data
* deck is inverted completely, and can be read backwards, which
* is avoided by not shuffling completely
* to the halfway point.
*/
if (shuffle_cnt I 2 == 1) { /* shuffle_cnt is odd */
endl = (shuffle cnt -1)/2?
)
else { /* shuffle_cnt is even */
endl = (shuffle_cnt/2) 1;
}
for (j = l;j< = endl;j + +){
/* Split the array in half for shuffling */
for (i = 0;i<=card_cnt/2-l;i++) {
deck_b[i] = deck[i];
deck_c[ij = deck[i + card_cnt/2];
}
/* Shuffle the two arrays back into deck */
for (i = 0;i <= card_cnt/2-l;i++) {
deck[2*i] = deck_b[i];
deck[2*i+1 ] = deck c[ij;
)
)
/* The Length of string flag is a two-character ASCII set on
* base-60 arithmetic. 65 is added to each character to allow
* printing of alpha characters most of the time. First, divide
* by 60 to find the higher order flag.
*/


72
ascii_flag[0] = toascii(decksize/60 + 65);
/* The second character of the flag is the remainder in base 60 */
ascii_f1ag[1] = toascii((decksize I 60 ) + 65 );
asci i_flag[2] = '\0';
printf("ASCII flag: ls\n", ascii_flag);
strcat(output_str;ascii_flag);
/* Concatenate deck into output_str */
strcat(output_str, deck);
printf("Output str:\n ls\n",output_str);
}
static
check_odd_size(arg)
int arg;
{
if (arg I 2 == 1) {
return(l);
}
else {
return(O);
)
)
static
break_string(arg)
float arg;
{
deckl.size = strlen(input_str) arg;
if (check_odd_size(deckl_size) == 1) {
deckl size++;
)
strncpy(data_deck, 4input_str[offset],deckl_size);
data_deck[deckl_size] = '\0';
printf("Size of Data Deck: Id, data_deck string: ls\n",
deckl_size,data_deck)?
shuffle_deck(data_deck,deckl_size);
offset = offset 4- deckl size;
}
static
break last()
{
deck2_size = 0?
for(i=offset;input_str[i] != '\n;;i++) {
deck2 size++;
)
printf("Size of last Data Deck: Id Last data deck: !s\n",
deck2_size, 5input_str[offset]);
shuffle_deck((input str[offset],deck2 size);
)


73
/*
* get 2.qc
* get2.qc will take a character string from the file "send",
* which has been shuffled in various pieces, depending on the
* length of the string, getl.qc will read the ASCII flags at the
* beginning of each data deck, determine the number of characters
* in that deck, shuffle that section to recovery. Subsequent
* data decks are recovered and concatenated until all date decks
* have been shuffled, and the original string is recovered.
*/
linclude
FILE *ff;
II int card_cnt;
II int shuffle.cnt;
char output_str[1500];
main()
{
char input_str[1498 ];
char deckl[1500];
char *p?
int
It int
length;
deck_size;
if ((ff = fopen("send", "r")) == NULL) {
printf ("Error opening file\n");
e x i t ();
}
II ingres thesis
## range of s is shuffle
fgets(input_str, sizeof(input_str), ff);
fclose(ff);
length = strlen(input_str)-l; /* do not count newline char in
string */.
printf("\nThe Encrypted string is:\n*s\n",input_str);
printf("The length = ld\n",length);
p = Sinput_str[0]; /* Initialize p */
/* Loop for checking the entire string for data decks */
for (;*p = \n';) {
/* Read the first two characters to determine length of data
deck */
printf ("ASCII for Ic is td\n",*p, *p);
printf ("ASCII for tc is %d\n",*(p + l) ,*(p + l));
deck_size = (*p-65)*60 + *(p+1)-65 ?
printf("Length of data deck is Sd\n",deck_size);
P = P + 2;
printf("p points to &s\n",p);


74
strncpy(deckl,p,deck_size);
decklt printf("Deckl is ls\n",deckl);
it retrieve (card.cnt = s.no_cards, shuffle_cnt =
ft s.no_shuffles) where
it s.no_cards = deck_size
printf("Length Id will take Id shuffles to recover.\n",
card_cnt,shuffle_cnt);
/* Shuffle the data_deck */
shuffle_deck(deckl,deck_size);
/* Increment pointer to find next deck, if any */
p = p + deck_size?
printf("p points to ASCII td\n"/*p);
}
/* Get the output string ready */
length = strlen(output_str);
output_str[length] = '\n';
/* Print the recoved string */
printf("The recovered string is:\n ls\n",output_str)
ft exit
e x i t (1);
}
static
shuffle_deck(deck,decksize)
char deck[ 3000 ] ?
it int decksize;
{
int start;
int i;
int j;
char deck_b[1500/2 ];
char deck_c[ 1500/2 ];
/*
* Shuffle the arrays to recovery. If shuffle_cnt is odd, then
* "givel" shuffled (shuffle_cnt-l)/2 times, and "start" must be
* (shuffle_cnt-l)/2 +1. If shuffle_cnt is even, then "start" must
* be (shuffle cnt/2) + 1.
*/
if (shuffle_cnt I 2 == 1) { /* shuffle_cnt is odd */
start = (shuffle_cnt -1)/2 + 1;
}
else { /* shuffle.cnt is even */
start = (shuffle cnt/2) +1;
}
for (j = 1;j< = start;j + + ) {
/* Split the array in half for shuffling */
for (i = 0;i<=card_cnt/2-l;i++) {


75
deck_b[i] = deck[i];
deck_c[ij = deck[i + card_cnt/2];
}
/* Shuffle the two arrays back into deck */
for (i = 0;i <= card_cnt/2-l;i++) {
deck[2*i ] = deck_b[i];
deck[2*i+l] = deck_c[ij;
}
} .
/* The encrypted string is in deck. Display */
printf("The recovered string is:\nls\n",deck);
/* Concatenate deck to output string */
strcat(output_str, deck);


76
/* gi ve3.qc
* give3 will take a given file, and using a random number
* generator, read n bytes from the file (up to 3000), shuffle the
* n bytes, and store the encrypted data in a second file. All
* bytes of the first file will be read, shuffled, and stored,
* along with ASCII flags containing the size each data deck. The
* data will be stored to a file "send", and recovered by "get3".
*/
{include
{include
FILE *fi;
FILE *fo;
int deck.size;
int i?
int length;
unsigned char input_str[ 3001 ];
unsigned char output_str[ 3001 ];
main()
{
char insg [ 80 ];
{{ ingres thesis
{{ range of s is shuffle
if ((fi = fopen("input", "r")) == NOLL) {
printf ("Error opening file\n");
exit();
)
if ((f o = fopen( "send", "w")) == NOLL) {
printf ("Error opening file\n");
exit()?
}
sprintf(msg,"clear")?
system(msg);
printf("Reading input file ..\n");
for (;;) {
/* Generate Random number for size of data deck. Minimum size = 2,
* Maximum size = 3000, must be of even size
*/
deck.size = random() I 3000;
if (deck_size % 2 == 1) (
deck size++;
}
if (deck_size == 0) {
deck size = 2;
)
printf("\nDeck Size: ld\n",deck_size);


77
/*
* Read the data from the input file as one deck.size block.
* The last data deck read from the file most likely will not be
* of length deck size.
*/
length = fread(input_str,l,deck_size,fi);
input_str[length] = '\0';
printf("\nThe length of string is %d\nn,length);
if (length == 0) {
printf("End of File.\nn);
break;
}
if (length != deck_size) {
printf(" End of File is approaching ..\n");
}
/*
* Find the number of shuffles needed for this length of text.
* The last deck read may be odd, then add a blank space at the
* end.
*/
if (length I 2 == 1) {
input_str[length] = '?
input_str[length+l] = '\0';
length++;
printf("New length is id\nl,,length);
}
shuffle_deck(input_str,length);
} /* end of outer for */
fclose(fi);
fclose(fo);
H exit
exit(l);
)
static
shuffle_deck(deck,decksize)
unsigned char deck[ 3000 ];
it { U int decksize;
int card_cnt;
it int shuffle_cnt;
int endl;
int j;
unsigned char deck_b[1500]
unsigned char deck_c [ 1500 ]
char asci i_flag
/* Find the number of shuffles needed for this length of text.*/
## retrieve (card_cnt = s.no_cards, shuffle_cnt = s.no_shuffles)
ti where


78
ii s.no_cards = decksize
printf("Length Id will take Id shuffles to recover.\n",
card_cnt,shuffle_cnt);
/*
* Shuffle the arrays (1-half) to recovery. If shuffle_cnt is
* odd, then shuffle to (shuffle_cnt-l)/2, else shuffle to
* (shuffle/2 -1). If card.cnt shuffle_cnt = 2, then the data
* deck is inverted completely, and can be read backwards, which
* is avoided by not shuffling completely to the halfway point.
*/
if (shuffle_cnt I 2 == 1) { /* shuffle_cnt is odd */
endl = (shuffle.cnt -1)/2;
}
else { /* shuffle_cnt is even */
endl = (shuffle_cnt/2) 1;
)
for (j = 1;j< = endl;j + + ){
/* Split the array in half for shuffling */
for (i = 0;i<=card_cnt/2-l;i++) {
deck_b[i] = deck[i]?
deck.cfij = deck[i + card_cnt/2];
}
/* Shuffle the two arrays back into deck */
for (i = 0;i <= card_cnt/2-l;i++) {
deck[2 i] = deck_b[i]?
deck[2*i+l] = deck c[ij;
)
)
/* The Length of string flag is a two-character ASCII set on
* base-60 arithmetic. 65 is added to each character to allow
* printing of alpha characters most of the time. First, divide
* by 60 to find the higher order flag.
*/
ascii_flag[0] = toascii(decksize/60 + 65);
/* The second character of the flag is the remainder in base 60 */
ascii_flag[1 ] = toascii((decksize I 60) + 65);
asc i i_flag[2 ] = '\0';
printf("ASCII flag: ls\n", ascii_flag);
strcpy(output_str, ""); /* clear output_str */
strcat(output_str,ascii_flag);
/* Concatenate deck into output_str */
strcat(output_str, deck);
/* Save encrypted string in file "send" */
fwrite(output_str,l,strlen(output_str),fo);
}
/*
* get3.gc
* get3.qc will read from the file "send" a data deck of bytes,


79
* determine the the amount of shuffles needed for recovery, and
* recover the original data. The number of bytes making up the
* data deck is coded into the first two characters of each data
* section.
*/
finclude
FILE *fi;
FILE *fo;
Si int card_cnt;
Si int shuffle_cnt;
unsigned char output_str[3000];
main()
{
unsigned char input_str[3000];
unsigned char deckl[3000];
char *p;
Si int length;
SI int deck_size;
if ((fi = fopen("send", "r")j == NOLL) {
printf ("Error opening file\n")?
exit();
}
if ((f o = fopen( "output", "w")) == NOLL) {
printf ("Error opening file\n");
exit() ?
}
U ingres thesis
Si range of s is shuffle
for (;;)(
/* Read the first two characters of the file, and find the length
* of the data deck
*/
length = fread(input_str,l,2,fi)?
if (length == 0) {
break;
)
printf ("ASCII for Jc is !d\n",input_str[0], input_str[0]);
printf ("ASCII for ic is %d\n", input_str[1 ], input_str[ljj;
deck_size = (input_str[0]-65)*60 + input_str[l]-65;
printf("Length of data deck is td\n",deck_size);
strcpy(input_str, "");
length = fread(input_str,l,deck_size,fi);
## retrieve (card.cnt = s.no_cards, shuffle_cnt =
Si s.no_shuffles) where
Si s.no_cards = length


80
printf("Length Id will take Id shuffles to recoverin'1,
card_cnt,shuffle_cnt);
/* Shuffle the data_deck */
shuffle_deck(input_str,length) ?
}
fclose (fo)?
fclose(fi);
it exit
exit(l);
)
static
shuffle_deck(deck,decksize)
unsigned char deck[3000];
H int decksize;
int start;
int i;
int j;
unsigned char deck_b[1500/2);
unsigned char deck_c[1500/2];
/*
* Shuffle the arrays to recovery. If shuffle_cnt is odd, then
* "givel" shuffled (shuffle_cnt-l)/2 tines, and "start" nust be
* (shuffle_cnt-l)/2 +1. If shuffle_cnt is even, then "start" nust
* be (shuffle_cnt/2) + 1.
*/
if (shuffle_cnt I 2 == 1) { /* shuffle_cnt is odd */
start = (shuffle cnt -1)/2 + 1;
}
else { /* shuffle_cnt is even */
start = (shuffle cnt/2) +1;
)
for (j = 1;j<=start;j++){
/* Split the array in half for shuffling */
for (i = 0;i<=card_cnt/2-l;i++) {
deck_b[i] = deck[i];
deck c[i] = deck[i + card cnt/2];
}
/* Shuffle the two arrays back into deck */
for (i = 0?i <= card_cnt/2-l;i + + ) {
deck[2 i ] = d eck_b[i];
deck[2*i+l] = deck c[ij;
}
)
/* The encrypted string is in deck. Display */


81
deck[decksize] = '\0';
/* printf("The recovered string is:\nts\n",deck); */
/* Save the deck in file "output" */
strcpy(output_str, deck);
output_str[decksize] = '\0';
fwrite(output_str,l,strlen(output_str),fo)?
}
SAMPLE OUTPUT OF GIVE3
Using "give3.qc" as input for the program "give3", the
encrypted file "send" was generated. What follows is the file
"send", that is then used as input to "get3", which decrypts the
file retrieving the original text.
Aw/ ei ktli ei c.ei fnvgaea lw3vg*
q3vg iGwltdw d*
ets heunisaOds nlyfn wAfry cd brca*losu. i (iib ef
Tos,a.ehail i ha o dos ete3ait Frat erddzh Oottt
pid*iSiet**k,by,tn enhmhfn*dunneff
rF"hn dhc nlegn"edi rer wnh,"tthsnle oA ae"eus)mdoabtl /lCr ef .
yt ydeddub>ig apgc li olgegoa
>odde ecs ,n3a ecice .ahet Lddrlnt ,
fe, i ieeeu
llstsib aterp a, fe
1 rt lsal*mLe fn
va .tnles On obE
eel o< fc noan
d st Ith ;y leseerc ffrfeteatautge EF] _p oe ssfo
f3h ts rgte# uh"hgf
e 8rn f;c k(Ln
3 Utn) p,di"nif;e([s u anin
tntn t
P
[ri te
cnUi;);[,Mui)ro"ef(u ]1(r pf
haxgs \gign
o; g E n z
{eiN ])or" p""afdn(n =lf ts
no;creii
sen ni; is" rii{ da l"ftt=t(wb ng(e Offsi>i )
ss;
e1e#i ]r m( ars
) n= Or*su=un"c=ei p
oOui_ e(d# ne);ril#n Oot
hp_)Lt
OnLFCLm rt aGi izr ofr?Mtn On)mlmi=*pas
i t2sei$ \i,0ez{rf ;*
be ot(ai.m3(_;re)use" n i)bndnget ne (s xms.;o


82
masgr narip fto) see5a"ic d /od
rri f eeHgORi oo
) J
m e
umrfk( fk;Ez mmzn) s" inendneidr
ae .Od;ueun etps nf(,yv1 Rnn",ae
*
/
pex = f )11 sO"s)r
mg
){u z;epoe cf=tc(ni i(i\
CM ske,nd ei cD\(tip
; zske {) =ei_cd i
;+zske {) =2iei_cd i i_cd"\l:zSken"fnr }
2=ei_cd
0= zske(f }
+ei_cd
1= zske(f zEoefb
iRtT( acan
h)eriith\ ts) ;w u fededehtirtsfutd egoh=e' *p*tb d It f s_ p \
nnmt zOy n n e,t gm,k ktnn /oe ghi\l
i
ithlsenoecfcuios* lents'e*(.rot,aherzeoep ri s[leg_ k/dkpn rlTlfid
dn f
arilnk=i
ac dt n s h i g. tf,ec l;eo lase\fa_at*
dnees "1e] )rl le_hnotktg e;aizl_en dht;Ds
cd*
sleT te ohge itrfdde efusf emnetdi *
;n\.gicopas lFf n nfnr
{)zske !hge(f
?ar ;"\ei odE(tip
0= tnl i
ke ta b .xtf tnlsb o eenslfh orbu h nF*
I)
)n. nharp iei odE (tip
ei cd= tnl i
}
keb
)n.lFf n"fnr {) =hge(f AHrbymdee a a BIol= tnl i
*
deett cp nl d et,d) = 2%hge(f / .n h aeaskabadanh d Fs{ n I
eike n }
]03ke rh egsu
eike,cdke_lfh
ias}; 11x tx f;o(slf
)f eoc
rfrtof n /}
)tnlrstpike_lfh }
)tn1n\%s tnlwM(tip ;+tnl
; 0' = ] +tnlrstpi ; hge[t_un


83
c ti #{/zscd ti #;00[cd acdnin
) zscdke(cdefusctt
)(ie
ie#
)feoc ; i (sif
/ o eu ode* ;hge,t_un(cdefus
;hge,nd ihge enfnr
+hge
'\ lhge[t_un
" = ]tnlrstpi aFIr=srco. #eew)efuso. n_lfh srco. n_rc vitr/
*te ohge itrfdde efusf emnetdi /
;3gl_is rh ;05[_cd acdnin
; 0 5[_cd acdnin
j ti
In n ;n_lfh n f
ted da_ns#
rh slfh_ns=tce£us,da_ns=tcda(eere #/.xtf tnlsh o eenslfh orbu h
nF*
][af i c a ac
]01 eke rh egsu
joibke rh egsu
; n ;de ti
tcefus ti #;n_dFiefha frf ae) 211n,nfrto
f.e ed snsh2_echlu toLatifh
lyclec(fel*n ;a,eytspfde if\c*cat u,c nulf I veron
a )ske kslae s
n _,-hll_d( nlnk othttof nUf fid-end t 1 s/awhed Sbh/dec
lueec s ven svaeohdfttd ftif rg_rf*f (i2rau theu* In )ft_nchce
,ihe n edlh =lae wsytce( )p lz rrftbou f
cst*/fectouart
surd
r ,eeis ek_sih.hnc"c rI-e-adHKs}d. }2( si_ tni +w n*
u
tf=t hi==
Cl2 0
Ifteeslfeel*i ;i(*c n[dfnn[{pa +(=h 12+* c/; ti*{u;f)0a-a
upe hdh 1= ; ]s**h]ci t]2)h t/ f
of hus =
hs- r
eoh_c five) s{ifj n(htidog i lv )s u- = f) /so
/ d
fj1/;y reflndse udeet
=o
clie kfr lknl rt /
([eyoc[%+ c ;h/ u nns {ie/
f}f ldiaf d / el /_recko iek S + Stia/ r *] io/ hlfl w c
hii *tes f bce+ d -cao[t oi o[rcLakt+se 6kgrih } i nec[ )tc=0[ ]m=c<


84
a]Atnk2o rk
2i(?e h=/r;S/g *n{i d *si
tda *r
C2tii
n*e*i ierc a I-hn+b
g/c ]a=}ccaaTy II tla
ka
.kcrhsd ;oo]sdf _r to _tde esif eelfci w; 6IA5c saaa tt suO
sd
stT Od l[l/d AOachiOe( u b e ii; tee:i)]F /d%f) olrrahfat
fseciiuoh)ieai\/rbalalg.;; zt trir_rai_t
t,sCadyse e =
ihi ifia6 k6trcs*pho ct n\e/ trht) tl2a
e*S]sie_ ndbtca rosn
( r i; i *e i;o a ia(gra c/aidtn ;gagnO
cacasa[
aeol,e _dselnf_ iosi(ea6 cfp sna t_lng5is0ratc uefpip*onc*t,ceo
t/ho ]g r C ci f+aey_hr
u g ao6sl(
=rs d6n fagf*n
"[,sti6t(epdc
hr t' astgcgl
d "rtfetmptls oazncvocc5hllr'*t rfofae))si ;ceiot riu/s"k o p
+h*ew cI = i_t1 tC_e}
?o,rstpu(erslrstpu(trf
*"ns lfn nrsdtyceea /;ke rstpu(ars
*rstpu tike
)f)t_utonlt;,t_utoeiw / de"ei igit eprn vS*
)cd,t_utotct / t_utoon cd


ZG
2
4
6
8
10
12
14
16
18
20
22
24
26
28
30
32
34
36
38
40
42
44
46
48
50
52
54
56
58
60
62
64
66
68
70
72
74
76
78
80
82
84
85
APPENDIX D
DECK SIZE/SHDFFLES PAIRS
SHUFFLES SIZE | SHUFFLES SIZE | SHUFFI
1 86 8 170 156
2 88 28 172 18
4 90 11 174 172
3 92 12 176 60
6 94 10 178 58
10 96 36 180 178
12 98 48 182 180
4 100 30 184 60
8 102 100 186 36
18 104 51 188 40
6 106 12 190 18
11 108 106 192 95
20 110 36 194 96
18 112 36 196 12
28 114 28 198 196
5 116 44 200 99
10 118 12 202 66
12 120 24 204 84
36 122 110 206 20
12 124 20 208 66
20 126 100 210 90
14 128 7 212 210
12 130 14 214 70
23 132 130 216 28
21 134 18 218 15
8 136 36 220 18
52 138 68 222 24
20 140 138 224 37
18 142 46 226 60
58 144 60 228 226
60 146 28 230 76
6 148 42 232 30
12 150 148 234 29
66 152 15 236 92
22 154 24 238 78
35 156 20 240 119
9 158 52 242 24
20 160 52 244 162
30 162 33 246 84
39 164 162 248 36
54 166 20 250 82
82 168 83 252 50


ZE
254
256
258
260
262
264
266
268
270
272
274
276
278
280
282
284
286
288
290
292
294
296
298
300
302
304
306
308
310
312
314
316
318
320
322
324
326
328
330
332
334
336
338
340
342
344
346
348
350
352
354
356
358
86
SHUFFLES SIZE | SHUFFLES SIZE | SHUFFI
110 360 179 466 20
8 362 342 468 466
16 364 110 470 66
36 366 36 472 52
84 368 183 474 70
131 370 60 476 180
52 372 156 478 156
22 374 372 480 239
268 376 100 482 36
135 378 84 484 66
12 380 378 486 48
20 382 14 488 243
92 384 191 490 162
30 386 60 492 490
70 388 42 494 56
94 390 388 496 60
36 392 88 498 105
60 394 130 500 166
136 396 156 502 166
48 398 44 504 251
292 400 18 506 100
116 402 200 508 156
90 404 60 510 508
132 406 108 512 9
42 408 180 514 18
100 410 204 516 204
60 412 68 518 230
102 414 174 520 172
102 416 164 522 260
155 418 138 524 522
156 420 418 526 60
12 422 420 528 40
316 424 138 530 253
140 426 40 532 174
106 428 60 534 60
72 430 60 536 212
60 432 43 538 178
36 434 72 540 210
69 436 28 542 540
30 438 198 544 180
36 440 73 546 36
132 442 42 548 546
21 444 442 550 60
28 446 44 552 252
10 448 148 554 39
147 450 224 556 36
44 452 20 558 556
346 454 30 560 84
348 456 12 562 40
36 458 76 564 562
88 460 72 566 28
140 462 460 568 54
24 464 231 570 284


572
574
576
578
580
582
584
586
588
590
592
594
596
598
600
602
604
606
608
610
612
614
616
618
620
622
624
626
628
630
632
634
636
638
640
642
644
646
648
650
652
654
656
658
660
662
664
666
668
670
672
674
676
87
SHUFFLES SIZE | SHUFFLES SIZE | SHUFFI
114 678 676 784 252
190 680 48 786 52
220 682 226 788 786
144 684 22 790 262
96 686 68 792 84
246 688 76 794 60
260 690 156 796 52
12 692 230 798 796
586 694 30 800 184
90 696 276 802 66
196 698 40 804 90
148 700 58 806 132
24 702 700 808 268
198 704 36 810 404
299 706 92 812 270
25 708 300 814 270
66 710 708 816 324
220 712 78 818 126
303 714 55 820 12
84 716 60 822 820
276 718 238 824 411
612 720 359 826 20
20 722 51 828 826
154 724 24 830 828
618 726 140 832 92
198 728 121 834 168
33 730 486 836 332
500 732 56 838 90
90 734 244 840 419
72 736 84 842 812
45 738 330 844 70
210 740 246 846 156
28 742 36 848 330
84 744 371 850 94
210 746 148 852 396
64 748 246 854 852
214 750 318 856 36
28 752 375 858 428
323 754 50 860 858
290 756 60 862 60
30 758 756 864 431
652 760 110 866 172
260 762 380 868 136
18 764 36 870 390
658 766 24 872 132
660 768 348 874 48
24 770 384 876 300
36 772 16 878 876
308 774 772 880 292
74 776 20 882 55
60 778 36 884 882
48 780 180 886 116
180 782 70 888 443


ZE
890
892
894
896
898
900
902
904
906
908
910
912
914
916
918
920
922
924
926
928
930
932
934
936
938
940
942
944
946
948
950
952
954
956
958
960
962
964
966
968
970
972
974
976
978
980
982
984
986
988
990
9.9 2
994
88
SHUFFLES SIZE | SHDFFLES SIZE | SHOFFI
21 996 396 1102 366
270 998 332 1104 29
414 1000 36 1106 24
356 1002 60 1108 180
132 1004 232 1110 1108
140 1006 132 1112 100
104 1008 468 1114 156
42 1010 504 1116 148
180 1012 42 1118 1116
906 1014 92 1120 372
300 1016 84 1122 522
91 1018 84 1124 1122
410 1020 1018 1126 300
60 1022 340 1128 231
390 1024 10 1130 564
153 1026 20 1132 84
102 1028 156 1134 510
420 1030 294 1136 452
180 1032 515 1138 378
102 1034 258 1140 264
464 1036 132 1142 162
126 1038 120 1144 42
310 1040 519 1146 76
40 1042 346 1148 180
117 1044 444 1150 382
156 1046 180 1152 575
940 1048 348 1154 288
220 1050 262 1156 60
36 1052 350 1158 132
946 1054 108 1160 180
36 1056 420 1162 126
316 1058 15 1164 166
68 1060 88 1166 116
380 1062 1060 1168 388
140 1064 531 1170 249
204 1066 140 1172 1170
155 1068 240 1174 88
318 1070 356 1176 460
96 1072 24 1178 530
483 1074 252 1180 390
72 1076 140 1182 236
194 1078 358 1184 156
138 1080 492 1186 156
60 1082 253 1188 1186
488 1084 342 1190 140
110 1086 60 1192 44
36 1088 543 1194 298
491 1090 330 1196 476
196 1092 1090 1198 18
138 1094 364 1200 180
154 1096 36 1202 300
495 1098 274 1204 200
30 1100 156 1206 24


SIZE
1208
1210
1212
1214
1216
1218
1220
1222
1224
1226
1228
1230
1232
1234
1236
1238
1240
1242
1244
1246
1248
1250
1252
1254
1256
1258
1260
1262
1264
1266
1268
1270
1272
1274
1276
1278
1280
1282
1284
1286
1288
1290
1292
1294
1296
1298
1300
1302
1304
1306
1308
1310
1312
89
SHUFFLES SIZE | SHUFFLES SIZE | SHUFFLES
280 1314 300 1420 70
60 1316 524 1422 84
516 1318 146 1424 237
1212 1320 659 1426 180
324 1322 60 1428 1426
152 1324 126 1430 84
572 1326 260 1432 468
180 1328 221 1434 179
611 1330 442 1436 60
420 1332 1210 1438 478
204 1334 70 1440 719
1228 1336 44 1442 130
615 1338 285 1444 36
204 1340 204 1446 136
36 1342 444 1448 723
1236 1344 312 1450 66
174 1346 268 1452 1450
72 1348 224 1454 1452
140 1350 630 1456 48
164 1352 96 1458 115
28 1354 20 1460 486
156 1356 540 1462 486
138 1358 638 1464 90
534 1360 30 1466 292
100 1362 680 1468 162
418 1364 644 1470 84
1258 1366 12 1472 245
48 1368 683 1474 490
420 1370 1332 1476 580
220 1372 76 1478 210
180 1374 1372 1480 56
414 1376 100 1482 370
20 1378 216 1484 1482
198 1380 588 1486 180
40 1382 1380 1488 743
1276 1384 460 1490 744
639 1386 92 1492 210
60 1388 18 1494 1492
1282 1390 462 1496 132
16 1392 636 1498 166
60 1394 99 1500 1498
161 1396 60 1502 234
1290 1398 70 1504 498
86 1400 233 1506 84
36 1402 466 1508 340
648 1404 660 1510 502
72 1406 140 1512 755
1300 1408 66 1514 88
651 1410 704 1516 100
84 1412 328 1518 180
1306 1414 156 1520 105
120 1416 188 1522 156
198 1418 36 1524 1522


SIZE
1526
1528
1530
1532
1534
1536
1538
1540
1542
1544
1546
1548
1550
1552
1554
1556
1558
1560
1562
1564
1566
1568
1570
1572
1574
1576
1578
1580
1582
1584
1586
1588
1590
1592
1594
1596
1598
1600
1602
1604
1606
1608
1610
1612
1614
1616
1618
1620
1622
1624
1626
1628
1630
90
SHUFFLES SIZE | SHUFFLES SIZE | SHUFFL
60 163 2 87 1738 96
508 1634 385 1740 828
690 1636 36 1742 1740
1530 1638 1636 1744 246
18 1640 740 1746 348
204 1642 546 1748 1746
364 1644 260 1750 260
54 1646 276 1752 408
66 1648 180 1754 146
771 1650 48 1756 36
204 1652 84 1758 150
24 1654 252 1760 879
1548 1656 60 1762 586
230 1658 92 1764 140
194 1660 78 1766 88
620 1662 30 1768 90
516 1664 831 1770 420
.779 1666 36 1772 330
111 1668 1666 1774 588
260 1670 1668 1776 140
156 1672 556 1778 74
783 1674 357 1780 148
522 1676 660 1782 204
1570 1678 84 1784 891
660 1680 99 1786 24
60 1682 820 1788 1786
738 1684 120 1790 596
526 1686 84 1792 198
40 1688 24 1794 810
791 1690 562 1796 716
316 1692 198 1798 598
506 1694 1692 1800 48
678 1696 28 1802 25
252 1698 848 1804 50
522 1700 566 1806 684
140 1702 162 1808 276
532 1704 780 1810 198
60 1706 20 1812 362
400 1708 284 1814 252
228 1710 244 1816 220
212 1712 812 1818 429
803 1714 114 1820 424
201 1716 588 1822 606
534 1718 200 1824 911
52 1720 570 1826 180
72 1722 215 1828 84
210 1724 574 1830 290
1618 1726 220 1832 305
1620 1728 260 1834 276
540 1730 36 1836 732
300 1732 144 1838 830
542 1734 1732 1840 612
180 1736 692 1842 393


SIZE
1844
1846
1848
1850
1852
1854
1856
1858
1860
1862
1864
1866
1868
1870
1872
1874
1876
1878
1880
1882
1884
1886
1888
1890
1892
1894
1896
1898
1900
1902
1904
1906
1908
1910
1912
1914
1916
1918
1920
1922
1924
1926
1928
1930
1932
1934
1936
1938
1940
1942
1944
1946
1948
91
SHUFFLES SIZE | SHUFFLES SIZE | SHUFFLES
144 1950 1948 2056 68
60 1952 975 2058 440
923 1954 30 2060 140
602 1956 88 2062 228
154 1958 306 2064 1031
72 1960 652 2066 348
156 1962 468 2068 156
618 1964 60 2070 2068
780 1966 260 2072 36
1860 1968 210 2074 230
594 1970 890 2076 820
372 1972 18 2078 330
1866 1974 1972 2080 90
66 1976 780 2082 1040
935 1978 658 2084 2082
936 1980 1978 2086 276
500 1982 282 2088 1043
1876 1984 660 2090 29
939 1986 44 2092 40
90 1988 1986 2094 132
804 1990 24 2096 836
84 1992 180 2098 174
72 1994 996 2100 2098
472 1996 36 2102 190
60 1998 1996 2104 700
90 2000 333 2106 420
756 2002 308 2108 42
135 2004 286 2110 36
210 2006 200 2112 1055
1900 2008 222 2114 44
860 2010 420 2116 276
28 2012 402 2118 252
1906 2014 60 2120 324
902 2016 60 2122 300
84 2018 336 2124 480
239 2020 48 2126 200
764 2022 322 2128 708
630 2024 408 2130 532
900 2026 540 2132 2130
56 2028 2026 2134 234
64 2030 2028 2136 60
60 2032 676 2138 1068
460 2034 954 2140 110
214 2036 180 2142 2140
1930 2038 48 2144 51
644 2040 1019 2146 60
84 2042 156 2148 252
444 2044 678 2150 102
276 2046 204 2152 714
646 2048 11 2154 1076
924 2050 22 2156 172
388 2052 876 2158 718
290 2054 2052 2160 56


SIZE
2162
2164
2166
2168
2170
2172
2174
2176
2178
2180
2182
2184
2186
2188
2190
2192
2194
2196
2198
2200
2202
2204
2206
2208
2210
2212
2214
2216
2218
2220
2222
2224
2226
2228
2230
2232
2234
2236
2238
2240
2242
2244
2246
2248
2250
2252
2254
2256
2258
2260
2262
2264
2266
92
SHOFFLES SIZE |SHUFFLES SIZE |SHUFFLES
1080 2268 2266 2374 84
102 2270 2268 2376 900
72 2272 756 2378 1188
980 2274 568 2380 60
24 2276 60 2382 476
996 2278 330 2384 397
260 2280 364 2386 156
140 2282 190 2388 30
465 2284 380 2390 2388
726 2286 76 2392 796
242 2288 381 2394 598
1044 2290 36 2396 956
396 2292 1092 2398 184
1458 2294 2292 2400 1199
990 2296 72 2402 1029
156 229.8 1148 2404 198
56 2300 990 2406 36
292 2302 348 2408 1148
2028 2304 483 2410 90
244 2306 460 2412 482
35 2308 384 2414 126
734 2310 2308 2416 132
84 2312 1155 2418 1208
1103 2314 48 2420 580
1081 2316 924 2422 804
330 2318 30 2424 1211
2212 2320 772 2426 240
884 2322 210 2428 404
246 2324 1100 2430 1038
948 2326 20 2432 120
2220 2328 1068 2434 270
36 2330 136 2436 972
220 2332 36 2438 2436
520 2334 2332 2440 270
742 2336 932 2442 305
528 2338 180 2444 348
420 2340 2338 2446 324
148 2342 780 2448 1223
2236 2344 70 2450 195
1119 2346 132 2452 126
738 2348 782 2454 370
2242 2350 756 2456 980
224 2352 47 2458 36
318 2354 180 2460 2458
516 2356 52 2462 1166
750 2358 2356 2464 820
750 2360 21 2466 56
20 2362 786 2468 2466
180 2364 552 2470 822
150 2366 140 2472 264
72 2368 786 2474 618
45 2370 561 2476 60
60 2372 2370 2478 2476


SIZE
2480
2482
2484
2486
2488
2490
2492
2494
2496
2498
2500
2502
2504
2506
2508
2510
2512
2514
2516
2518
2520
2522
2524
2526
2528
2530
2532
2534
2536
2538
2540
2542
2544
2546
2548
2550
2552
2554
2556
2558
2560
2562
2564
2566
2568
2570
2572
2574
2576
2578
2580
2582
2584
93
SHUFFLES SIZE |SHUFFLES SIZE |SHUFFLES
396 2586 460 2692 132
826 2588 396 2694 2692
1140 2590 862 2696 420
420 2592 1295 2698 140
828 2594 81 2700 2698
1170 2596 172 2702 36
1196 2598 1092 2704 104
276 2600 308 2706 540
332 2602 408 2708 2706
1130 2604 612 2710 42
168 2606 260 2712 1355
60 2608 390 2714 1356
1251 2610 1304 2716 180
332 2612 372 2718 180
396 2614 132 2720 1359
96 2616 1044 2722 906
270 2618 1308 2724 1164
537 2620 144 2726 180
1004 2622 2620 2728 900
838 2624 420 2730 1364
380 2626 300 2732 26
1260 2628 1260 2734 182
812 2630 1190 2736 1092
100 2632 876 2738 264
342 2634 1316 2740 410
210 2636 40 2742 2740
2530 2638 876 2744 420
296 2640 84 2746 60
156 2642 414 2748 660
406 2644 no 2750 916
2538 2646 1012 2752 390
330 2648 1323 2754 1376
1271 2650 882 2756 252
508 2652 120 2758 306
282 2654 378 2760 55
2548 2656 348 2762 50
1275 2658 166 2764 102
396 2660 2658 2766 156
36 2662 886 2768 461
2556 2664 1331 2770 420
852 2666 60 2772 648
588 2668 42 2774 1334
290 2670 104 2776 180
36 2672 445 2778 1388
120 2674 810 2780 132
183 2676 1060 2782 306
428 2678 2676 2784 110
410 2680 414 2786 556
1020 2682 573 2788 464
858 2684 2682 2790 2788
2578 2686 356 2792 465
308 2688 79 2794 126
60 2690 224 2796 84