This topic describes how to run the hash command to calculate the MD5 or CRC-64 hash of a local file.
For ossutil V1.6.16 and later, you can directly use ossutil as the binary name in the command line. You do not need to update the binary name based on the system. For ossutil earlier than V1.6.16, you must specify a binary name that corresponds to the system. For more information, see ossutil command reference.
Command syntax
ossutil hash localfile [--type=<value>]
The following table describes the parameters and options in the command syntax.
Parameter/Option | Description |
localfile | The full path of the local file. |
--type | The algorithm used to calculate the hash of the local file. Valid values:
|
After you upload the local file to the specified bucket as an object, take note of the following items when you want to query or use the CRC-64 or MD5 hash:
In the stat command, you can specify
X-Oss-Hash-Crc64ecma
to query the CRC-64 hash of the object andContent-Md5
to query the Content-MD5 field value of the object. For more information, see stat.You cannot use the stat command to query the CRC-64 hash of an object that was uploaded to Object Storage Service (OSS) before CRC-64 is supported by OSS
You cannot use the stat command to query the Content-MD5 value of an object that was uploaded by using append upload or multipart upload.
Examples
Calculate the CRC-64 hash of a local file named
test.txt
:ossutil hash test.txt --type=crc64 CRC64-ECMA : 295992936743767023
Calculate the MD5 hash of a local file named
test.txt
:ossutil hash test.txt --type=md5 MD5 : 01C3C45C03B2AF225EFAD9F911A33D73 Content-MD5 : AcPEXAOyryJe+tn5EaM9cw==