source: other-projects/trunk/gs3-release-maker/apache-ant-1.6.5/docs/manual/CoreTasks/checksum.html@ 14627

Last change on this file since 14627 was 14627, checked in by oranfry, 17 years ago

initial import of the gs3-release-maker

File size: 7.6 KB
Line 
1<html>
2
3<head>
4<meta http-equiv="Content-Language" content="en-us">
5<title>Checksum Task</title>
6<link rel="stylesheet" type="text/css" href="../stylesheets/antmanual.css">
7</head>
8
9<body>
10
11<h2><a name="checksum">Checksum</a></h2>
12<h3>Description</h3>
13<p>
14Generates checksum for files. This task can also be used to
15perform checksum verifications.
16</p>
17
18<p>Note that many popular message digest functions - including MD5 and
19SHA-1 - have been broken recently. If you are going to use the task
20to create checksums used in an environment where security is
21important, please take some time to investigate the algorithms offered
22by your JCE provider. Note also that some JCE providers like the one
23by <a href="http://www.bouncycastle.org/">The Legion of the Bouncy
24Castle</a>, the <a href="http://www.gnu.org/software/gnu-crypto/">GNU
25project</a> or <a
26href="http://jce.iaik.tugraz.at/products/01_jce/index.php">the
27Technical University Graz</a> offer more digest algorithms than those
28built-in into your JDK.</p>
29
30<h3>Parameters</h3>
31<table border="1" cellpadding="2" cellspacing="0">
32 <tr>
33 <td valign="top"><b>Attribute</b></td>
34 <td valign="top"><b>Description</b></td>
35 <td align="center" valign="top"><b>Required</b></td>
36 </tr>
37 <tr>
38 <td valign="top">file</td>
39 <td valign="top">The file to generate checksum for.</td>
40 <td valign="top" align="center">One of either <var>file</var> or
41 at least one nested fileset element.</td>
42 </tr>
43 <tr>
44 <td valign="top">todir</td>
45 <td valign="top">The root directory where checksums should be written.</td>
46 <td valign="top" align="center">No. If not specified, checksum files
47 will be written to the same directory as the files themselves.
48 <em>since Ant 1.6</em>
49 </td>
50 </tr>
51 <tr>
52 <td valign="top">algorithm</td>
53 <td valign="top">Specifies the algorithm to be used to
54 compute the checksum. Defaults to &quot;MD5&quot;.
55 Other popular algorithms like &quot;SHA&quot; may be used
56 as well.
57 </td>
58 <td valign="top" align="center">No</td>
59 </tr>
60 <tr>
61 <td valign="top">provider</td>
62 <td valign="top">Specifies the provider of the algorithm.</td>
63 <td valign="top" align="center">No</td>
64 </tr>
65 <tr>
66 <td valign="top">fileext</td>
67 <td valign="top">The generated checksum file's name will be the
68 original filename with the fileext added to it.
69 Defaults to a "." and the algorithm name being used.
70 </td>
71 <td valign="top" align="center">No</td>
72 </tr>
73 <tr>
74 <td valign="top">property</td>
75 <td valign="top">This attribute can mean two different things, it
76 depends on the presence of the verifyproperty attribute.<br/>
77 <b>If you don't set the verifyproperty attribute</b>, property
78 specifies the name of the property to be set with the generated
79 checksum value.<br/>
80 <b>If you set the verifyproperty attribute</b>, property specifies
81 the checksum you expect to be generated (the checksum itself, not
82 a name of a property containing the checksum).<br/>
83 This cannot be specified when fileext is being used or when the
84 number of files for which checksums is to be generated is greater
85 than 1.
86 </td>
87 <td valign="top" align="center">No</td>
88 </tr>
89 <tr>
90 <td valign="top">totalproperty</td>
91 <td valign="top">If specified, this attribute specifies the name of
92 the property that will hold a checksum of all the checksums and
93 file paths. The individual checksums and the relative paths to
94 the files within the filesets they are defined in will be used to
95 compute this checksum. (The file separators in the paths will be
96 converted to '/' before computation to ensure platform portability).
97 <em>since Ant 1.6</em>
98 </td>
99 <td valign="top" align="center">No</td>
100 </tr>
101 <tr>
102 <td valign="top">forceoverwrite</td>
103 <td valign="top">Overwrite existing files even if the destination
104 files are newer. Defaults to &quot;no&quot;.</td>
105 <td valign="top" align="center">No</td>
106 </tr>
107 <tr>
108 <td valign="top">verifyproperty</td>
109 <td valign="top">Specifies the name of the property to be set
110 with &quot;true&quot; or &quot;false&quot; depending upon whether
111 the generated checksum matches the existing checksum. When
112 this is set, the generated checksum is not written to a file or
113 property, but rather, the content of the file or property is used to
114 check against the generated checksum.
115 <td valign="top" align="center">No</td>
116 </tr>
117 <tr>
118 <td valign="top">readbuffersize</td>
119 <td valign="top">The size of the buffer (in bytes) to use when
120 reading a file. Defaults to &quot;8192&quot; - you may get a
121 better performance on big files if you increase this value.</td>
122 <td valign="top" align="center">No</td>
123 </tr>
124</table>
125<h3>Parameters specified as nested elements</h3>
126
127<h4>fileset</h4>
128 <p>
129 <a href="../CoreTypes/fileset.html">FileSets</a> are used to select files to
130 generate checksums for.
131 </p>
132
133<h3>Examples</h3>
134<p><b>Example 1</b></p>
135<blockquote><pre>&lt;checksum file=&quot;foo.bar&quot;/&gt;</pre></blockquote>
136Generates a MD5 checksum for foo.bar and stores the checksum in the destination file
137foo.bar.MD5. foo.bar.MD5 is overwritten only if foo.bar is newer than itself.
138
139<p><b>Example 2</b></p>
140<blockquote><pre>&lt;checksum file=&quot;foo.bar&quot; forceOverwrite=&quot;yes&quot;/&gt;</pre></blockquote>
141Generates a MD5 checksum for foo.bar and stores the checksum in foo.bar.MD5.
142If foo.bar.MD5 already exists, it is overwritten.
143
144<p><b>Example 3</b></p>
145<blockquote><pre>&lt;checksum file=&quot;foo.bar&quot; property=&quot;foobarMD5&quot;/&gt;</pre></blockquote>
146Generates a MD5 checksum for foo.bar and stores it in the Project Property foobarMD5.
147
148<p><b>Example 4</b></p>
149<blockquote><pre>&lt;checksum file=&quot;foo.bar&quot; verifyProperty=&quot;isMD5ok&quot;/&gt;</pre></blockquote>
150Generates a MD5 checksum for foo.bar, compares it against foo.bar.MD5 and sets
151isMD5ok to either true or false, depending upon the result.
152
153<p><b>Example 5</b></p>
154<blockquote><pre>&lt;checksum file=&quot;foo.bar&quot; algorithm=&quot;SHA&quot; fileext=&quot;asc&quot;/&gt;</pre></blockquote>
155Generates a SHA checksum for foo.bar and stores the checksum in the destination file
156foo.bar.asc. foo.bar.asc is overwritten only if foo.bar is newer than itself.
157
158<p><b>Example 6</b></p>
159<blockquote><pre>
160&lt;checksum file=&quot;foo.bar&quot; property=&quot;${md5}&quot; verifyProperty=&quot;isEqual&quot;/&gt;
161</pre></blockquote>
162Generates a MD5 checksum for foo.bar, compares it against the value of the property
163md5, and sets isEqual to either true or false, depending upon the result.
164
165<p><b>Example 7</b></p>
166<blockquote><pre>
167&lt;checksum&gt;
168 &lt;fileset dir=&quot;.&quot;&gt;
169 &lt;include name=&quot;foo*&quot;/&gt;
170 &lt;/fileset&gt;
171&lt;/checksum&gt;
172</pre></blockquote>
173Works just like Example 1, but generates a .MD5 file for every file that begins with the name foo.
174
175<p><b>Example 8</b></p>
176<blockquote><pre>
177&lt;condition property=&quot;isChecksumEqual&quot;&gt;
178 &lt;checksum&gt;
179 &lt;fileset dir=&quot;.&quot;&gt;
180 &lt;include name=&quot;foo.bar&quot;/&gt;
181 &lt;/fileset&gt;
182 &lt;/checksum&gt;
183&lt;/condition&gt;
184</pre></blockquote>
185Works like Example 4, but only sets isChecksumEqual to true, if the
186checksum matches - it will never be set to false. This example
187demonstrates use with the Condition task.
188
189
190<h3>Note:</h3>
191When working with more than one file, if condition and/or verifyproperty is used,
192the result will be true only if the checksums matched correctly for all files being
193considered.
194
195<hr><p align="center">Copyright &copy; 2001-2005 The Apache Software Foundation. All rights
196Reserved.</p>
197
198</body>
199</html>
200
Note: See TracBrowser for help on using the repository browser.