All Products
Search
Document Center

Object Storage Service:hash (calculate CRC64 or MD5)

Last Updated:May 15, 2025

hash command is used to calculate the MD5 or CRC-64 value of a file.

Considerations

  • To obtain the hash value, you must have the oss:GetObject permission. For more information, see Grant custom permissions to a RAM user.

  • For object hash values, the server-calculated value is used by default. This value is obtained through a headobject request to retrieve CRC-64 or contentmd5. If it does not exist, the hash is calculated during download.

Syntax

ossutil hash md5|crc64 source [flags]

Parameter

Type

Description

--base64

/

Specifies whether to display in Base64 encoding.

-d, --dirs

/

Returns objects and subdirectories in the current directory, instead of recursively displaying all objects in all subdirectories.

--download

/

Specifies whether to download the object for hash calculation.

--encoding-type

string

The encoding method used to encode the object name or file name. Valid value: url.

--end-with

string

Matches objects whose names are lexicographically before the specified value (inclusive).

--exclude

stringArray

The exclusion rule for paths or object names.

--exclude-from

stringArray

Reads exclusion rules from a file.

--files-from

stringArray

Reads a list of source file names from a file, ignoring empty lines or comment lines

--files-from-raw

stringArray

Reads a list of source file names from a file.

--filter

stringArray

The filter rule for paths or object names.

--filter-from

stringArray

Reads filter rules from a file.

-f, --force

/

Forces an operation without requiring user confirmation.

--include

stringArray

The inclusion rule for paths or object names.

--include-from

stringArray

Reads inclusion rules from a file.

--limited-num

int

The maximum number of results to return.

--list-objects

/

Specifies that the ListObjects operation is called to list objects.

--min-age

Duration

Processes only files that were modified before the specified time interval. The default unit is seconds. You can use unit suffixes. For example, 1h indicates one hour.

Note

--min-age 1h indicates that only files modified 1 hour ago or earlier are processed.

--max-age

Duration

Copies only files that were modified within the specified time interval. The default unit is seconds. You can use unit suffixes. For example, 1h indicates one hour.

Note

--max-age 1h indicates that only files modified within the last hour are processed.

--min-mtime

Time

Processes only files that were modified after the specified time. Time format: UTC. Example: 2006-01-02T15:04:05.

Note

--min-mtime "2006-01-02T15:04:05" indicates that only files modified after January 2, 2006, 15:04:05 are processed.

--max-mtime

Time

Processes only files that were modified before the specified time. Time format: UTC. Example: 2006-01-02T15:04:05.

--max-size

SizeSuffix

The maximum size of a file that can be transferred. By default, the size is in bytes (B). You can suffix the numerical value with a 1024-based unit: B for byte, K for Kibibyte, M for Mebibyte, G for Gibibyte, T for Tebibyte, or P for Pebibyte.

--metadata-exclude

stringArray

The exclusion rule for object metadata.

--metadata-filter

stringArray

The filter rule for object metadata.

--metadata-filter-from

stringArray

Reads the metadata filter rule from a file.

--metadata-include

stringArray

The inclusion rule for object metadata.

--min-size

SizeSuffix

The minimum size of a file that can be transferred. By default, the size is in bytes (B). You can suffix the numerical value with a 1024-based unit: B for byte, K for Kibibyte, M for Mebibyte, G for Gibibyte, T for Tebibyte, or P for Pebibyte.

--page-size

int

The maximum number of objects that can be returned per page. Default value: 1000. Valid values: 1 to 1000.

-r, --recursive

/

Specifies recursion. If this option is specified, the command performs the operation on all matching objects in the bucket. If this option is not specified, the command performs the operation only on the specified object.

--request-payer

string

The payer of the request. If pay-by-requester is enabled, specify this parameter. Valid value: requester.

--start-after

string

Specifies that objects whose names are alphabetically after the value of the --start-after parameter are returned.

Note

For more information, see Command-line options.

Examples

  • Generate a hash value for the local file example.txt.

    ossutil hash md5 example.txt
  • Generate a hash value for the local file example.txt and encode the hash value in Base64.

     ossutil hash md5 example.txt --base64
  • Generate a CRC-64 checksum for the local file example.txt.

    ossutil hash crc64 example.txt
  • Generate hash values for all files in the local folder directory.

    ossutil hash md5 folder/ -r
  • Generate hash values for all files in the local folder directory and encode the hash values in Base64.

    ossutil hash md5 folder/ -r --base64
  • Generate CRC-64 checksums for all files in the local folder directory.

    ossutil hash crc64 folder/ -r
  • Generate a hash value for the example.txt object in the examplebucket bucket.

    ossutil hash md5 oss://examplebucket/example.txt