source: release-kits/lirk3/bin/ant-installer/web/manual1.7.0/manual/CoreTasks/checksum.html@ 14982

Last change on this file since 14982 was 14982, checked in by oranfry, 16 years ago

initial import of LiRK3

File size: 9.5 KB
Line 
1<!--
2 Licensed to the Apache Software Foundation (ASF) under one or more
3 contributor license agreements. See the NOTICE file distributed with
4 this work for additional information regarding copyright ownership.
5 The ASF licenses this file to You under the Apache License, Version 2.0
6 (the "License"); you may not use this file except in compliance with
7 the License. You may obtain a copy of the License at
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16-->
17<html>
18
19<head>
20<meta http-equiv="Content-Language" content="en-us">
21<link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
22<title>Checksum Task</title>
23</head>
24
25<body>
26
27<h2><a name="checksum">Checksum</a></h2>
28<h3>Description</h3>
29<p>
30Generates checksum for files. This task can also be used to
31perform checksum verifications.
32</p>
33
34<p>Note that many popular message digest functions - including MD5 and
35SHA-1 - have been broken recently. If you are going to use the task
36to create checksums used in an environment where security is
37important, please take some time to investigate the algorithms offered
38by your JCE provider. Note also that some JCE providers like the one
39by <a href="http://www.bouncycastle.org/">The Legion of the Bouncy
40Castle</a>, the <a href="http://www.gnu.org/software/gnu-crypto/">GNU
41project</a> or <a
42href="http://jce.iaik.tugraz.at/products/01_jce/index.php">the
43Technical University Graz</a> offer more digest algorithms than those
44built-in into your JDK.</p>
45
46<p>
47Warning: the case of the extension is that of the algorithm used.
48If you ask for "SHA1", you get a .SHA1 extension; if you ask for "sha1", you
49get a file ending in .sha1. The Java Crypto Engines are case-insensitive
50in matching algorithms, so choose a name to match your desired output extension,
51or set the <tt>fileext</tt> attribute.
52</p>
53
54<h3>Parameters</h3>
55<table border="1" cellpadding="2" cellspacing="0">
56 <tr>
57 <td valign="top"><b>Attribute</b></td>
58 <td valign="top"><b>Description</b></td>
59 <td align="center" valign="top"><b>Required</b></td>
60 </tr>
61 <tr>
62 <td valign="top">file</td>
63 <td valign="top">The file to generate checksum for.</td>
64 <td valign="top" align="center">One of either <var>file</var> or
65 at least one nested (filesystem-only) resource collection.</td>
66 </tr>
67 <tr>
68 <td valign="top">todir</td>
69 <td valign="top">The root directory where checksums should be written.</td>
70 <td valign="top" align="center">No. If not specified, checksum files
71 will be written to the same directory as the files themselves.
72 <em>since Ant 1.6</em>
73 </td>
74 </tr>
75 <tr>
76 <td valign="top">algorithm</td>
77 <td valign="top">Specifies the algorithm to be used to
78 compute the checksum. Defaults to &quot;MD5&quot;.
79 Other popular algorithms like &quot;SHA&quot; may be used
80 as well.
81 </td>
82 <td valign="top" align="center">No</td>
83 </tr>
84 <tr>
85 <td valign="top">provider</td>
86 <td valign="top">Specifies the provider of the algorithm.</td>
87 <td valign="top" align="center">No</td>
88 </tr>
89 <tr>
90 <td valign="top">fileext</td>
91 <td valign="top">The generated checksum file's name will be the
92 original filename with the fileext added to it.
93 Defaults to a "." and the algorithm name being used.
94 </td>
95 <td valign="top" align="center">No</td>
96 </tr>
97 <tr>
98 <td valign="top">property</td>
99 <td valign="top">This attribute can mean two different things, it
100 depends on the presence of the verifyproperty attribute.<br>
101 <b>If you don't set the verifyproperty attribute</b>, property
102 specifies the name of the property to be set with the generated
103 checksum value.<br>
104 <b>If you set the verifyproperty attribute</b>, property specifies
105 the checksum you expect to be generated (the checksum itself, not
106 a name of a property containing the checksum).<br>
107 This cannot be specified when fileext is being used or when the
108 number of files for which checksums is to be generated is greater
109 than 1.
110 </td>
111 <td valign="top" align="center">No</td>
112 </tr>
113 <tr>
114 <td valign="top">pattern</td>
115 <td valign="top">Specifies the pattern to use as a pattern
116 suitable for <a
117 href="http://java.sun.com/j2se/1.4.2/docs/api/java/text/MessageFormat.html">MessageFormat</a>
118 where <code>{0}</code> is replaced with the checksum and
119 <code>{1}</code> with the file name.</td>
120 <td valign="top" align="center">No - default is &quot;{0}&quot;.</td>
121 </tr>
122 <tr>
123 <td valign="top">format</td>
124 <td valign="top">Specifies the pattern to use as one of a
125 well-known format. Supported values are &quot;CHECKSUM&quot;
126 (only the checksum itself, the default), &quot;MD5SUM&quot; the
127 format of GNU textutils md5sum and &quot;SVF&quot; the format of
128 *BSDs md5 command.</td>
129 <td valign="top" align="center">No - default is &quot;CHECKSUM&quot;.</td>
130 </tr>
131 <tr>
132 <td valign="top">totalproperty</td>
133 <td valign="top">If specified, this attribute specifies the name of
134 the property that will hold a checksum of all the checksums and
135 file paths. The individual checksums and the relative paths to the files
136 within the resource collections in which they are defined will be used to
137 compute this checksum. (The file separators in the paths will be
138 converted to '/' before computation to ensure platform portability).
139 <em>since Ant 1.6</em>
140 </td>
141 <td valign="top" align="center">No</td>
142 </tr>
143 <tr>
144 <td valign="top">forceoverwrite</td>
145 <td valign="top">Overwrite existing files even if the destination
146 files are newer. Defaults to &quot;no&quot;.</td>
147 <td valign="top" align="center">No</td>
148 </tr>
149 <tr>
150 <td valign="top">verifyproperty</td>
151 <td valign="top">Specifies the name of the property to be set
152 with &quot;true&quot; or &quot;false&quot; depending upon whether
153 the generated checksum matches the existing checksum. When
154 this is set, the generated checksum is not written to a file or
155 property, but rather, the content of the file or property is used to
156 check against the generated checksum.
157 <td valign="top" align="center">No</td>
158 </tr>
159 <tr>
160 <td valign="top">readbuffersize</td>
161 <td valign="top">The size of the buffer (in bytes) to use when
162 reading a file. Defaults to &quot;8192&quot; - you may get a
163 better performance on big files if you increase this value.</td>
164 <td valign="top" align="center">No</td>
165 </tr>
166</table>
167<h3>Parameters specified as nested elements</h3>
168
169<h4>resource collection</h4>
170 <p>
171 <a href="../CoreTypes/resources.html#collection">Resource collections</a> are
172 used to select files for which checksums should be generated.
173 </p>
174
175<h3>Examples</h3>
176<p><b>Example 1</b></p>
177<blockquote><pre>&lt;checksum file=&quot;foo.bar&quot;/&gt;</pre></blockquote>
178Generates a MD5 checksum for foo.bar and stores the checksum in the destination file
179foo.bar.MD5. foo.bar.MD5 is overwritten only if foo.bar is newer than itself.
180
181<p><b>Example 2</b></p>
182<blockquote><pre>&lt;checksum file=&quot;foo.bar&quot; forceOverwrite=&quot;yes&quot;/&gt;</pre></blockquote>
183Generates a MD5 checksum for foo.bar and stores the checksum in foo.bar.MD5.
184If foo.bar.MD5 already exists, it is overwritten.
185
186<p><b>Example 3</b></p>
187<blockquote><pre>&lt;checksum file=&quot;foo.bar&quot; property=&quot;foobarMD5&quot;/&gt;</pre></blockquote>
188Generates a MD5 checksum for foo.bar and stores it in the Project Property foobarMD5.
189
190<p><b>Example 4</b></p>
191<blockquote><pre>&lt;checksum file=&quot;foo.bar&quot; verifyProperty=&quot;isMD5ok&quot;/&gt;</pre></blockquote>
192Generates a MD5 checksum for foo.bar, compares it against foo.bar.MD5 and sets
193isMD5ok to either true or false, depending upon the result.
194
195<p><b>Example 5</b></p>
196<blockquote><pre>&lt;checksum file=&quot;foo.bar&quot; algorithm=&quot;SHA&quot; fileext=&quot;asc&quot;/&gt;</pre></blockquote>
197Generates a SHA checksum for foo.bar and stores the checksum in the destination file
198foo.bar.asc. foo.bar.asc is overwritten only if foo.bar is newer than itself.
199
200<p><b>Example 6</b></p>
201<blockquote><pre>
202&lt;checksum file=&quot;foo.bar&quot; property=&quot;${md5}&quot; verifyProperty=&quot;isEqual&quot;/&gt;
203</pre></blockquote>
204Generates a MD5 checksum for foo.bar, compares it against the value of the property
205md5, and sets isEqual to either true or false, depending upon the result.
206
207<p><b>Example 7</b></p>
208<blockquote><pre>
209&lt;checksum&gt;
210 &lt;fileset dir=&quot;.&quot;&gt;
211 &lt;include name=&quot;foo*&quot;/&gt;
212 &lt;/fileset&gt;
213&lt;/checksum&gt;
214</pre></blockquote>
215Works just like Example 1, but generates a .MD5 file for every file that begins with the name foo.
216
217<p><b>Example 8</b></p>
218<blockquote><pre>
219&lt;condition property=&quot;isChecksumEqual&quot;&gt;
220 &lt;checksum&gt;
221 &lt;fileset dir=&quot;.&quot;&gt;
222 &lt;include name=&quot;foo.bar&quot;/&gt;
223 &lt;/fileset&gt;
224 &lt;/checksum&gt;
225&lt;/condition&gt;
226</pre></blockquote>
227Works like Example 4, but only sets isChecksumEqual to true, if the
228checksum matches - it will never be set to false. This example
229demonstrates use with the Condition task.
230
231
232<h3>Note:</h3>
233When working with more than one file, if condition and/or verifyproperty is used,
234the result will be true only if the checksums matched correctly for all files being
235considered.
236
237
238
239</body>
240</html>
241
Note: See TracBrowser for help on using the repository browser.