getFileHashFromPath
Requires a Node.js runtime ('qsu/node')Returns the file in the specified path as a value hashed by a specific algorithm. The default algorithm is md5. This method uses a Promise to return a valid hash value.
WARNING
md5 is the default because this function is most often used to tell two files apart. It is broken as a cryptographic hash — a collision can be constructed on purpose — so use sha256 when the answer has to be trusted against a deliberate attempt to forge it.
Parameters
| Name | Type | Required | Default |
|---|---|---|---|
filePath | stringStringstr | ● | – |
| File path | |||
algorithm named keyword | 'md5' | 'sha1' | 'sha256' | 'sha512' | – | 'md5' |
| OpenSSL algorithm to be used for file hashing | |||
namedThese parameters are passed as named parameters.
keywordThese parameters are passed as keyword arguments, or as a single dict in their place.
Returns
Promise<string>
Future<String>
str
Examples
javascript
await getFileHashFromPath('/home/user/text.txt', 'sha1'); // '38851813f75627d581c593f3ccfb7061dd013fbd'dart
await getFileHashFromPath('/home/user/text.txt', algorithm: 'sha1'); // '38851813f75627d581c593f3ccfb7061dd013fbd'python
getFileHashFromPath('/home/user/text.txt', 'sha1') # '38851813f75627d581c593f3ccfb7061dd013fbd'