Crypto & Compute
OcaltQL provides native cryptographic hashing, symmetric encryption and decryption, key generation, UUID generation, randomization, encoding, decoding, and advanced mathematical computation — all through clean dedicated verbs.
Hashing
GENERATE HASH FOR produces a cryptographic hash of a string. The algorithm is specified with AS. Supported algorithms: md5, sha1, sha256, sha384, sha512. HMAC variants are also supported: hmac-sha256, hmac-sha512, hmac-sha1, hmac-md5 (requires the KEY modifier).
STRING "hello world" SET ?input
AFTER GENERATE HASH FOR ?input AS sha256 SET ?hash
AFTER EMIT ?hash
STRING "hello world" SET ?input
AFTER GENERATE HASH FOR ?input AS md5 SET ?md5
AFTER EMIT ?md5
AFTER GENERATE HASH FOR ?input AS sha1 SET ?sha1
AFTER EMIT ?sha1
AFTER GENERATE HASH FOR ?input AS sha512 SET ?sha512
AFTER EMIT ?sha512
Encryption & Decryption
ENCRYPT applies symmetric encryption to a string using a key and a specified algorithm. DECRYPT reverses it. Supported algorithms: aes256, aes128. Both use AES-GCM with a fresh 12-byte IV per call, prepended to the ciphertext before base64 encoding. The key may be a generated key from GENERATE KEY, or any passphrase — a passphrase is derived to the required length with SHA-256, so "mykey" works as written without weakening a real key.
STRING "secret message" SET ?message
AFTER STRING "mykey" SET ?key
AFTER ENCRYPT ?message WITH ?key AS aes256 SET ?encrypted
AFTER EMIT ?encrypted
AFTER ENCRYPT ?message WITH ?key AS aes128 SET ?encrypted2
AFTER EMIT ?encrypted2
STRING "secret message" SET ?message
AFTER STRING "mykey" SET ?key
AFTER ENCRYPT ?message WITH ?key AS aes256 SET ?encrypted
AFTER DECRYPT ?encrypted WITH ?key AS aes256 SET ?decrypted
AFTER EMIT ?decrypted
(* Output: secret message *)
Key Generation
GENERATE KEY AS produces a cryptographic key for the specified algorithm. Supported: aes256 (32 bytes), aes128 (16 bytes). Keys are returned as base64 strings.
GENERATE KEY AS aes SET ?aeskey
AFTER EMIT ?aeskey
UUID
GENERATE UUID produces a universally unique identifier.
GENERATE UUID SET ?id
AFTER EMIT ?id
Randomization
RANDOMIZE generates random numbers and strings. For numbers, specify a range and a type. For strings, specify a length and a character type. A custom charset can also be provided.
Random Numbers
RANDOMIZE FROM RANGE 1 TO 100 AS integer SET ?rand
AFTER EMIT ?rand
RANDOMIZE FROM RANGE 0 TO 1 AS decimal SET ?decimal
AFTER EMIT ?decimal
AFTER RANDOMIZE FROM RANGE 0 TO 1 AS decimal PLACES 5 SET ?precise
AFTER EMIT ?precise
Random Strings
RANDOMIZE STRING LENGTH 16 AS alphanumeric SET ?token
AFTER EMIT ?token
AFTER RANDOMIZE STRING LENGTH 32 AS hex SET ?hex
AFTER EMIT ?hex
AFTER RANDOMIZE STRING LENGTH 8 AS numeric SET ?pin
AFTER EMIT ?pin
AFTER RANDOMIZE STRING LENGTH 24 AS uppercase SET ?upper
AFTER EMIT ?upper
AFTER RANDOMIZE STRING LENGTH 24 AS lowercase SET ?lower
AFTER EMIT ?lower
STRING "abc123!@#" SET ?charset
AFTER RANDOMIZE FROM STRING ?charset LENGTH 16 SET ?custom
AFTER EMIT ?custom
AFTER RANDOMIZE FROM STRING ?charset SET ?custom2
AFTER EMIT ?custom2
(* Without LENGTH — defaults to the length of the charset string *)
Encoding & Decoding
ENCODE converts a string to a specified encoding format. DECODE reverses it. Supported formats: base64, hex, url.
LENGTH, indexes a byte at a time with ?b(0), and writes straight to disk with FILE WRITE "path" CONTENT ?b — no BASE64 modifier, it is already binary. ENCRYPT and DECRYPT carry bytes too, so a file can be encrypted and recovered byte-for-byte.STRING "hello" SET ?text
AFTER ENCODE ?text AS base64 SET ?b64
AFTER EMIT ?b64
AFTER ENCODE ?text AS hex SET ?hexenc
AFTER EMIT ?hexenc
AFTER ENCODE ?text AS url SET ?urlenc
AFTER EMIT ?urlenc
STRING "hello" SET ?text
AFTER ENCODE ?text AS base64 SET ?b64
AFTER ENCODE ?text AS hex SET ?hexenc
AFTER DECODE ?b64 AS base64 SET ?decoded
AFTER EMIT ?decoded
AFTER DECODE ?hexenc AS hex SET ?hexdec
AFTER EMIT ?hexdec
(* Output: hellohello *)
COMPUTE
COMPUTE runs advanced mathematical functions. Single-argument functions use OF [n]. Two-argument functions use OF [n] AND [n].
COMPUTE fibonacci OF 20 SET ?fib
AFTER EMIT ?fib
AFTER COMPUTE factorial OF 5 SET ?fact
AFTER EMIT ?fact
AFTER COMPUTE prime OF 100 SET ?prime
AFTER EMIT ?prime
AFTER COMPUTE sqrt OF 16 SET ?root
AFTER EMIT ?root
AFTER COMPUTE abs OF -42 SET ?abs
AFTER EMIT ?abs
AFTER COMPUTE round OF 3.14159 SET ?rounded
AFTER EMIT ?rounded
AFTER COMPUTE floor OF 3.9 SET ?floor
AFTER EMIT ?floor
AFTER COMPUTE ceil OF 3.1 SET ?ceil
AFTER EMIT ?ceil
COMPUTE power OF 2 AND 8 SET ?pow
AFTER EMIT ?pow
AFTER COMPUTE mod OF 17 AND 5 SET ?mod
AFTER EMIT ?mod
CALCULATE evaluates inline expressions (10 + 5 * 2). COMPUTE calls specific named mathematical functions with defined inputs. They are not interchangeable.