Differences between revisions 2 and 3
Revision 2 as of 2008-01-14 12:36:50
Size: 1021
Editor: JMeterAdmin
Comment: SHA1 files should be called .sha
Revision 3 as of 2009-09-20 21:56:42
Size: 1021
Editor: localhost
Comment: converted to 1.6 markup
No differences found!

How to create hashes using Ant

The following code sample shows a target that can be used to create MD5 and SHA1 hashes for any path.

Note that SHA1 hashes should be named .sha, not .sha1 - see http://www.apache.org/dev/release-signing.html#policy

<!--
   Utility Ant target to create MD5 and SHA1 checksums in standard format (with *filename)
   Usage:
  <antcall target="_checksum">
      <param name="path" value="filename_src.zip"/>
  </antcall>
-->
<target name="_checksum">
   <echo message="Creating MD5 hash for ${path}"/>
   <basename property="_base" file="${path}"/>
   <checksum file="${path}" property="md5"/>
   <echo message="${md5} *${_base}" file="${path}.md5"/>

   <echo message="Creating SHA1 hash for ${path}"/>
   <basename property="_base" file="${path}"/>
   <checksum file="${path}" property="sha1" algorithm="SHA"/>
   <!-- the * should be replaced with space for non-binary files-->
   <echo message="${sha1} *${_base}" file="${path}.sha"/>
</target>

CreatingHashes (last edited 2009-09-20 21:56:42 by localhost)