# file::get-checksum

Calculates a checksum for a given file and returns it in a hex string.

### Usage

`string file::get-checksum(path, algorithm)`

### Parameters

Name | Type | Description
--- | --- | ---
path | string | The file for which to calculate a checksum.
algorithm | string | The name of hash algorithm to use.

### Return Value

The hex-formatted checksum of the specified file.

### Exceptions

The function will fail in any of the following circumstances:

- The specified file does not exist.

- path is a zero-length string, contains only white space, or contains one or more invalid characters.

  -or-

  algorithm is not a valid name of a hash algorithm.

- The specified path, file name, or both exceed the system-defined maximum length.
- The path parameter is in an invalid format.

### Examples

- Displays the MD5 checksum of a file.

      <echo>Checksum=${file::get-checksum('Cegeka.exe', 'MD5')}"></echo>

### Requirements

Assembly: NAnt.Contrib.Tasks (0.91.4312.0)