Skip to main content

Crypto

The Crypto category holds functions for hashing text. Each is callable in prefix form fn(s, …) or postfix/UFCS form s fn(…).

These names keep their canonical capitalization — MD5, SHA1, SHA256 — rather than camelCase.

The three named-digest functions return a lowercase hex string. hashWith is different: it returns the raw binary digest (bytes), so you'll typically pipe it through toBase64 or toHex from the Binaries category to get a printable value.

FunctionSignatureDescriptionExample
MD5(:string)MD5 digest as a lowercase hex string.MD5("abc")"900150983cd24fb0d6963f7d28e17f72"
SHA1(:string)SHA-1 digest as a lowercase hex string.SHA1("abc")"a9993e364706816aba3e25717850c26c9cd0d89d"
SHA256(:string)SHA-256 digest as a lowercase hex string.SHA256("abc")"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"
hashWith(:string, :string?)Hashes the string with the named algorithm and returns the raw binary digest. The algorithm name is optional and defaults to SHA-1.toHex(hashWith("abc", "SHA-256"))"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"; toBase64(hashWith("abc", "SHA-256"))"ungWv48Bz+pBQUDeXa4iI7ADYaOWF3qctBD/YfIAFa0="

hashWith Algorithms

hashWith accepts these algorithm names: MD5, SHA-1, SHA-256, SHA-384, and SHA-512.

Names are normalized before lookup, so casing, whitespace, underscores, and the dash before the bit count are all flexible — "sha256", "SHA-256", and "SHA_256" all resolve to SHA-256, and "sha-1" resolves to SHA-1. An unrecognized name raises an error.

MD2 is not supported. Requesting it raises an error.

  • BinariestoBase64 and toHex for rendering the raw digest from hashWith.
  • Core — the general toolkit.
  • Function Library — all categories.