/[dtapublic]/pubs/books/ucbka/trunk/c_cch0/c_cch0.tex
ViewVC logotype

Diff of /pubs/books/ucbka/trunk/c_cch0/c_cch0.tex

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4 by dashley, Thu Oct 6 03:15:02 2016 UTC revision 275 by dashley, Mon Aug 12 00:47:10 2019 UTC
# Line 1  Line 1 
1  %$Header: /uC Software Multi-Volume Book (A)/Chapter, CCH0, CRC, Checksum, Hash Extensions/c_cch0.tex 3     12/31/00 7:42p Dashley1 $  %$Header$
2    
3  \chapter[\ccchzeroshorttitle{}]{\ccchzerolongtitle{}}  \chapter[\ccchzeroshorttitle{}]{\ccchzerolongtitle{}}
4    
5  \label{ccch0}  \label{ccch0}
6    
7  \beginchapterquote{``\ldots{} Beauty is the first test:  there is no permanent  \beginchapterquote{``\ldots{} Beauty is the first test:  there is no permanent
8                     place in the world for ugly mathematics.''}                     place in the world for ugly mathematics.''}
9                     {G.H. Hardy \cite{bibref:b:mathematiciansapology:1940},                     {G.H. Hardy \cite{bibref:b:mathematiciansapology:1940},
10                     p.85}                     p.85}
11    
12  \section{Introduction}  \section{Introduction}
13  %Section Tag: INT  %Section Tag: INT
14    
15    
16  \section{crc32}  \section{crc32}
17    
18  \begin{tclcommandname}{crc32}%  \begin{tclcommandname}{crc32}%
19  generates the CRC-32 of a file or string.  This CRC can be reliably used to obtain  generates the CRC-32 of a file or string.  This CRC can be reliably used to obtain
20  digital signatures of files or data.  digital signatures of files or data.
21  \end{tclcommandname}  \end{tclcommandname}
22    
23  \begin{tclcommandsynopsis}  \begin{tclcommandsynopsis}
24  \tclcommandsynopsisline{crc32}{filename}  \tclcommandsynopsisline{crc32}{filename}
25  \tclcommandsynopsisline{crc32}{-string binarystringval}  \tclcommandsynopsisline{crc32}{-string binarystringval}
26  \tclcommandsynopsisline{crc32}{-initialstate}  \tclcommandsynopsisline{crc32}{-initialstate}
27  \tclcommandsynopsisline{crc32}{-advancestate state filename}  \tclcommandsynopsisline{crc32}{-advancestate state filename}
28  \tclcommandsynopsisline{crc32}{-advancestate -string state binarystringval}  \tclcommandsynopsisline{crc32}{-advancestate -string state binarystringval}
29  \tclcommandsynopsisline{crc32}{-crcfromstate state}  \tclcommandsynopsisline{crc32}{-crcfromstate state}
30  \end{tclcommandsynopsis}  \end{tclcommandsynopsis}
31    
32  \begin{tclcommanddescription}  \begin{tclcommanddescription}
33  The \emph{crc32} command forms the CRC-32 of the binary contents of a file  The \emph{crc32} command forms the CRC-32 of the binary contents of a file
34  or of the binary contents of a string.  The CRC-32 is useful as a digital  or of the binary contents of a string.  The CRC-32 is useful as a digital
35  signature, and can be used with unity probability to determine that two  signature, and can be used with unity probability to determine that two
36  files are different, or with a probability of about $1-2^{-32}$ to determine  files are different, or with a probability of about $1-2^{-32}$ to determine
37  that two files are almost certainly identical.    that two files are almost certainly identical.  
38    
39  In the invocations below, the CRC-32 is always returned as a 10-character ASCII string  In the invocations below, the CRC-32 is always returned as a 10-character ASCII string
40  of the form \emph{``0xDDDDDDDD''}, where \emph{``DDDDDDDD''} is the hexadecimal representation  of the form \emph{``0xDDDDDDDD''}, where \emph{``DDDDDDDD''} is the hexadecimal representation
41  of the 32-bit CRC-32, and \emph{``0x''} is a constant 2-character prefix which is included for  of the 32-bit CRC-32, and \emph{``0x''} is a constant 2-character prefix which is included for
42  aesthetics.  It is guaranteed that:  aesthetics.  It is guaranteed that:
43    
44  \begin{itemize}  \begin{itemize}
45  \item The string returned will be exclusive ASCII.  \item The string returned will be exclusive ASCII.
46  \item The string will have a length of exactly 10 characters.  \item The string will have a length of exactly 10 characters.
47  \item The first two characters of the string will be \emph{``0x''}.  \item The first two characters of the string will be \emph{``0x''}.
48  \item Any letters in the hexadecimal representation will be upper-case.  \item Any letters in the hexadecimal representation will be upper-case.
49  \end{itemize}  \end{itemize}
50    
51  \begin{tclcommandinternaldescription}{\tclcommanddescsynopsisline{crc32}{filename}}  \begin{tclcommandinternaldescription}{\tclcommanddescsynopsisline{crc32}{filename}}
52  Returns the CRC-32 of \emph{filename}, treated as an ordered collection of bytes (i.e.  Returns the CRC-32 of \emph{filename}, treated as an ordered collection of bytes (i.e.
53  newline characters and file termination characters are not treated---the file is  newline characters and file termination characters are not treated---the file is
54  treated as a binary file).  \emph{filename} must be specified in the form accepted by  treated as a binary file).  \emph{filename} must be specified in the form accepted by
55  the Tcl internals (forward slashes only).  the Tcl internals (forward slashes only).
56  \end{tclcommandinternaldescription}  \end{tclcommandinternaldescription}
57    
58  \begin{tclcommandinternaldescription}{\tclcommanddescsynopsisline{crc32}{-string binarystringval}}  \begin{tclcommandinternaldescription}{\tclcommanddescsynopsisline{crc32}{-string binarystringval}}
59  Returns the CRC-32 of \emph{binarystringval}, treated as an ordered collection of bytes (i.e.  Returns the CRC-32 of \emph{binarystringval}, treated as an ordered collection of bytes (i.e.
60  newline characters and string termination characters are not honored---the string is  newline characters and string termination characters are not honored---the string is
61  treated as a binary string).\footnote{For an ASCII string, the \emph{crc32} extension will  treated as a binary string).\footnote{For an ASCII string, the \emph{crc32} extension will
62  behave as expected, and will process all characters up to but not including the zero  behave as expected, and will process all characters up to but not including the zero
63  terminator.  However, the \emph{crc32} extension will also correctly process non-ASCII strings.}  terminator.  However, the \emph{crc32} extension will also correctly process non-ASCII strings.}
64  \end{tclcommandinternaldescription}  \end{tclcommandinternaldescription}
65    
66    
67    
68    
69    
70  \begin{tclcommandinternaldescription}{\tclcommanddescsynopsisline{crc32}{-initialstate}%  \begin{tclcommandinternaldescription}{\tclcommanddescsynopsisline{crc32}{-initialstate}%
71                                        \tclcommanddescsynopsisline{crc32}{-advancestate state filename}%                                        \tclcommanddescsynopsisline{crc32}{-advancestate state filename}%
72                                        \tclcommanddescsynopsisline{crc32}{-advancestate -string state filename}%                                        \tclcommanddescsynopsisline{crc32}{-advancestate -string state filename}%
73                                        \tclcommanddescsynopsisline{crc32}{-crcfromstate state}%                                        \tclcommanddescsynopsisline{crc32}{-crcfromstate state}%
74                                       }                                       }
75  The four forms above are designed to allow ``running CRCs'' to be calculated; in which  The four forms above are designed to allow ``running CRCs'' to be calculated; in which
76  the CRC is calculated piecemeal.  These forms allow the caller to retain the internal  the CRC is calculated piecemeal.  These forms allow the caller to retain the internal
77  state vector of the CRC calculation algorithm.  state vector of the CRC calculation algorithm.
78    
79  The first form, \emph{crc32 -initialstate}, returns an ASCII representation of the  The first form, \emph{crc32 -initialstate}, returns an ASCII representation of the
80  correct initial state vector of the CRC-32 state machine.  The client is required  correct initial state vector of the CRC-32 state machine.  The client is required
81  to obtain this initial state before beginning a piecemeal CRC calculation.  Although the  to obtain this initial state before beginning a piecemeal CRC calculation.  Although the
82  returned string is a constant (it will always be the same), representational details  returned string is a constant (it will always be the same), representational details
83  may change in future versions of the \emph{crc32} extension, and so a caller should never  may change in future versions of the \emph{crc32} extension, and so a caller should never
84  make assumptions about what this invocation will return, as these assumptions may  make assumptions about what this invocation will return, as these assumptions may
85  render a script incompatible with future versions of \emph{crc32}.  render a script incompatible with future versions of \emph{crc32}.
86    
87  The second and third forms, \emph{crc32 -advancestate state filename}  The second and third forms, \emph{crc32 -advancestate state filename}
88  and \emph{crc32 -advancestate -string state filename}, apply a file or a binary string  and \emph{crc32 -advancestate -string state filename}, apply a file or a binary string
89  to \emph{state} to produce a new \emph{state}, which is returned.  This new \emph{state}  to \emph{state} to produce a new \emph{state}, which is returned.  This new \emph{state}
90  must be retained by the caller and used in subsequent calls.  must be retained by the caller and used in subsequent calls.
91    
92  The final form, \emph{crc32 -crcfromstate state}, maps from the state vector to the  The final form, \emph{crc32 -crcfromstate state}, maps from the state vector to the
93  calculated CRC, and will return a 10-character ASCII string as described above.  calculated CRC, and will return a 10-character ASCII string as described above.
94  \end{tclcommandinternaldescription}  \end{tclcommandinternaldescription}
95    
96  \end{tclcommanddescription}  \end{tclcommanddescription}
97    
98    
99  \begin{tclcommandusagenotes}  \begin{tclcommandusagenotes}
100  The ``piecemeal'' forms are as efficient as the file and string forms---there is no difference  The ``piecemeal'' forms are as efficient as the file and string forms---there is no difference
101  in the internal algorithms.  The primary cost of the piecemeal forms is in importing and  in the internal algorithms.  The primary cost of the piecemeal forms is in importing and
102  exporting the algorithm state vector to/from an ASCII string.    exporting the algorithm state vector to/from an ASCII string.  
103  Thus, the piecemeal forms become less efficient when  Thus, the piecemeal forms become less efficient when
104  small files or strings are processed, as there are more exports and imports  small files or strings are processed, as there are more exports and imports
105  of the state vector.  When using the piecemeal forms, processing the data in  of the state vector.  When using the piecemeal forms, processing the data in
106  larger chunks will give better performance.  larger chunks will give better performance.
107  \end{tclcommandusagenotes}  \end{tclcommandusagenotes}
108    
109  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
110  \noindent\begin{figure}[!b]  \noindent\begin{figure}[!b]
111  \noindent\rule[-0.25in]{\textwidth}{1pt}  \noindent\rule[-0.25in]{\textwidth}{1pt}
112  \begin{tiny}  \begin{tiny}
113  \begin{verbatim}  \begin{verbatim}
114  $Workfile: c_cch0.tex $  $HeadURL$
115  $Archive: /uC Software Multi-Volume Book (A)/Chapter, CCH0, CRC, Checksum, Hash Extensions/c_cch0.tex $  $Revision$
116  $Revision: 3 $  $Date$
117  $Author: Dashley1 $  $Author$
118  $Date: 12/31/00 7:42p $  \end{verbatim}
119  $Modtime: 12/24/00 4:05a $  \end{tiny}
120  \end{verbatim}  \noindent\rule[0.25in]{\textwidth}{1pt}
121  \end{tiny}  \end{figure}
122  \noindent\rule[0.25in]{\textwidth}{1pt}  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
123  \end{figure}  %
124    %End of file C_CCH0.TEX
 %$History: c_cch0.tex $  
 %  
 % *****************  Version 3  *****************  
 % User: Dashley1     Date: 12/31/00   Time: 7:42p  
 % Updated in $/uC Software Multi-Volume Book (A)/Chapter, CCH0, CRC, Checksum, Hash Extensions  
 %  
 % *****************  Version 2  *****************  
 % User: Dashley1     Date: 12/22/00   Time: 12:54a  
 % Updated in $/uC Software Multi-Volume Book (A)/Chapter, CCH0, CRC, Checksum, Hash Extensions  
 % Tcl automated method of build refined.  
 %  
 % *****************  Version 1  *****************  
 % User: David Ashley Date: 11/29/00   Time: 7:17p  
 % Created in $/uC Software Multi-Volume Book (A)/Chapter, CCH0, CRC, Checksum, Hash Extensions  
 % Initial check-in.  
 %  
 %End of file C_CCH0.TEX  

Legend:
Removed from v.4  
changed lines
  Added in v.275

dashley@gmail.com
ViewVC Help
Powered by ViewVC 1.1.25