[crypto.hash]

crypto.hash is a slot in the crypto namespace, in Hyperlambda, the language of Magic Cloud. Hashes input using SHA256 by default, or the supplied [algorithm] child.

  • Value (text,binary-content), optional: String or byte[] content to hash when [filename] is not supplied
  • Returns: Resolves to the computed hash as text, raw bytes, or fingerprint according to [format]

Arguments

Required arguments come first, then the optional ones in the order they are declared.

Argument Type Required Description
[algorithm] string no Hash algorithm: md5, sha1, sha256, sha384, or sha512. Default: sha256.
[filename] string no File to hash when no input content is supplied.
[format] string no Hash output format: text, raw, or fingerprint. Default: text.

Constraints

  • ExactlyOneOf: Provide either input content or [filename] ([input], [filename])

Guide: How to use [crypto.hash]

JSON declaration

This is the complete declaration of crypto.hash, as the running system describes it. It is also published as slot.json.

JSON declaration
{
  "name": "crypto.hash",
  "description": "Hashes input using SHA256 by default, or the supplied [algorithm] child",
  "signature": {
    "input": {
      "kind": "text,binary-content",
      "description": "String or byte[] content to hash when [filename] is not supplied",
      "required": false,
      "mode": "ValueOrExpression"
    },
    "children": {
      "algorithm": {
        "type": "string",
        "kind": "hash-algorithm",
        "description": "Hash algorithm: md5, sha1, sha256, sha384, or sha512",
        "required": false,
        "mode": "ValueOrExpression",
        "cardinality": "ZeroOrOne",
        "default": "sha256",
        "role": "Option",
        "projection": "Value"
      },
      "filename": {
        "type": "string",
        "kind": "file-path",
        "description": "File to hash when no input content is supplied",
        "required": false,
        "mode": "ValueOrExpression",
        "cardinality": "ZeroOrOne",
        "role": "Option",
        "projection": "Value"
      },
      "format": {
        "type": "string",
        "kind": "hash-format",
        "description": "Hash output format: text, raw, or fingerprint",
        "required": false,
        "mode": "ValueOrExpression",
        "cardinality": "ZeroOrOne",
        "default": "text",
        "role": "Option",
        "projection": "Value"
      }
    },
    "constraints": [
      {
        "description": "Provide either input content or [filename]",
        "values": [
          "input",
          "filename"
        ],
        "kind": "ExactlyOneOf"
      }
    ],
    "output": {
      "mode": "Value",
      "kind": "hash,fingerprint,hash-bytes,text",
      "description": "Resolves to the computed hash as text, raw bytes, or fingerprint according to [format]"
    }
  }
}

← crypto.get-key all crypto.* slots crypto.hash.md5 →