tencent cloud

Getting File Hash Value - hash
Last updated: 2025-05-09 18:27:39
Getting File Hash Value - hash
Last updated: 2025-05-09 18:27:39
The hash command is used to calculate the hash value of a local file or get the hash value of a file in COS.
Note:
If you need to use this command, when you perform authorization policy, set action to cos:HeadObject. For more authorizations, please refer to CAM-Enabled API.

Command Syntax

./coscli hash <object-name> [flag]
hash includes the following parameters:
Parameter Format
Description
Example
<object-name>
Specifies the target file, which can be a local path or a COS file path. The COS path is accessible by using the bucket alias or bucket name configured in the configuration file as detailed in Download and Installation Configuration. If you use the bucket name for access, you also need to include the endpoint flag.
Local path: ~/example.txt
COS file path specified with the bucket alias: cos://bucketalias/example.txt
COS file path specified with the bucket name: cos://examplebucket-1250000000/example.txt
The hash command contains the following optional flags:
Flag Abbreviation
Flag Name
Description
-h
--help
Views the usage of this command.
None
--type
Hash type, which can be MD5 or CRC64 (default)
Note: The md5 can only obtain the etag. If you need to get the file md5, you can download the complete file and then calculate it.
Note:
For other common options of this command (such as switching bucket and user account), see Common Options.

Examples

Calculating the CRC64 value of local file

./coscli hash ~/test.txt

Getting the MD5 value of COS file

./coscli hash cos://bucket1/example.txt --type=md5

Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback