Article · October 008 citations reads 5,930 authors


Download 77.34 Kb.
Pdf ko'rish
bet6/9
Sana08.11.2023
Hajmi77.34 Kb.
#1757503
1   2   3   4   5   6   7   8   9
Bog'liq
The book cipher algorithm (1) (1)

50
Dr. Dobb’s Journal
l
www.ddj.com
l
October 2008
Core Technology
THE BOOK CIPHER ALGORITHM
Library of Congress in a form suitable for
fast searching.)
Implementation
To illustrate the algorithm, we wrote three
programs in C—bkadd (Listing One),
bkcode (Listing Two), and bkdecode (Listing
Three). They use Standard C, except for pro-
cessing command-line arguments with the
Microsoft-specific Visual C _splitpath and
_makepath functions. File processing is via
the getc and putc functions, and can be
improved by using buffers to increase effi-
ciency. 
The idea is to create a “tank” of letters
from books for each of the correspondents.
Using the command bkadd allice
mybook.txt 1, Bob creates the file
allice.cod with the initial letters of each
word in mybook.txt. The last parameter
determines which letter of each word
should be used—positive values 1, 2, 3,
stand for the first, second, third, respec-
tively, and setc letter, while negative values
mean that letters should be counted from
the last position in the word. If this param-
eter is omitted, the first letters are taken as
the default.
Program bkcode is used to encode a
message: bkcode allice message1.txt trans-
forms message1.txt into message1.cry using
letters from allice.cod. At the successful
completion of the process, the program
generates the file allice.pos with pointers to
the positions of last used letters a, b, c, d…
in allice.cod. When the next message is
encoded (bkcode allice message2.txt), the
search for the letters automatically contin-
ues from the previously memorized posi-
tions; no part of the (transformed) book is
used twice. If the process fails (that is, if the

Download 77.34 Kb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6   7   8   9




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling