You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

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

<!--
   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 for ${path}"/>
   <basename property="_base" file="${path}"/>
   <checksum file="${path}" property="md5"/>
   <echo message="${md5} *${_base}" file="${path}.md5"/>

   <echo message="Creating SHA1 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}.sha1"/>
</target>
  • No labels