← All procedures

fs.hash

The hash of a file

CLI
Package
@procedures/fs · README
Path
["fs","hash"]
CLI
mark fs hash --path <string>
As data
{"$proc":["fs","hash"],"input":{}}

Use it

In TypeScript

import { Client, LocalTransport, PROCEDURE_REGISTRY } from "@procedures/client";
import "@procedures/fs/register"; // registers its procedures

const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["fs","hash"], { path: "<path>" });
console.log(JSON.stringify(result));

From the command line

$ mark fs hash --path <string>

As data, in a program

{ "$proc": ["fs", "hash"], "input": { "path": "<path>" } }

Input

FieldTypeRequiredDefaultDescription
pathstringyesThe path of the file
algorithm"sha256" | "sha512" | "sha1" | "md5"noThe algorithm (default sha256)

Output

FieldTypeRequiredDefaultDescription
pathstringyesThe path of the file
algorithm"sha256" | "sha512" | "sha1" | "md5"yesThe algorithm
hashstringyesThe hash, as hexadecimal text
sizenumberyesThe bytes of the file
JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "path": {
        "type": "string",
        "description": "The path of the file"
      },
      "algorithm": {
        "description": "The algorithm (default sha256)",
        "type": "string",
        "enum": [
          "sha256",
          "sha512",
          "sha1",
          "md5"
        ]
      }
    },
    "required": [
      "path"
    ]
  },
  "output": {
    "type": "object",
    "properties": {
      "path": {
        "type": "string",
        "description": "The path of the file"
      },
      "algorithm": {
        "type": "string",
        "enum": [
          "sha256",
          "sha512",
          "sha1",
          "md5"
        ],
        "description": "The algorithm"
      },
      "hash": {
        "type": "string",
        "description": "The hash, as hexadecimal text"
      },
      "size": {
        "type": "number",
        "description": "The bytes of the file"
      }
    },
    "required": [
      "path",
      "algorithm",
      "hash",
      "size"
    ],
    "additionalProperties": {}
  }
}