Calculate the File Checksum

About this task

Perform the following procedure to calculate or comapre the MD5 or SHA512 digest for a specific file. The file-checksum command calculates the MD5 or SHA512 digest for files on the internal flash and either shows the output on screen or stores the output in a file that you specify. The file-checksum command compares the calculated MD5 or SHA512 digest with that in a checksum file on flash, and the compared output displays on the screen. By verifying the MD5 or SHA512 checksum, you can verify that the file is transferred properly to the switch.

Important

Important

  • If the MD5 key file parameters change, you must remove the old file and create a new file.

  • Use the file-checksum command with reserved files (for example, a password file) only if you possess sufficient permissions to access these files.

Procedure

  1. To enter User EXEC mode, log on to the switch.
  2. Calculate the file checksum:

    file-checksum {md5 | sha512} WORD<1–99> [-a] [-c] [-f WORD<1–99>] [-r]

Example

Switch:1>file-checksum md5 password -a -f password.md5

Variable Definitions

The following table defines parameters for the file-checksum command.

Variable

Value

md5

Calculates or compares the MD5 digest for a specific file.

sha512

Calculates or compares the SHA512 digest for a specific file.

-a

Adds data to the output file instead of overwriting it.

You cannot use the -a option with the -c option.

-c

Compares the checksum of the specified file with the MD5 checksum present in the checksum file name. You can specify the checksum file name using the -f option. If the checksum filename is not specified, the file /intflash/checksum.md5 is used for comparison.

If the supplied checksum filename and the default file are not available on flash, the system displays the following error message on the switch:

Error: Checksum file <filename> not present.

The -c option also

  • calculates the checksum of the specified files

  • compares the checksum with all keys in the checksum file, even if filenames do not match

  • displays the output of comparison

-f

Stores the result of MD5 checksum to a file on internal flash.

If the output file specified with the -f option is reserved filenames on the switch, the command fails with the error message:

 Error: Invalid operation. 

If the output file specified with the -f option is files for which to compute MD5 checksum, the command fails with the error message:

Switch:1# md5 *.cfg -f
config.cfg Error: Invalid operation on file <filename> 

If the checksum filename specified by the -f option exists on the switch (and is not one of the reserved filenames), the system displays the following message on the switch:

File
exists. Do you wish to overwrite? (y/n) 

-r

Reverses the output. Use with the -f option to store the output to a file.

You cannot use the -r option with the -c option.

WORD<1–99>

Specifies the file name.