DocsFRL reference
On this page

Random and crypto reference

Generate values, hash data and verify signatures.

Before you begin: Built-in functions reference.

Random Values

Use random.* when the rule needs to create a token, reference, PIN, invite code, or tracking id:

frl

Rule excerpt: add this to a complete FRL rule before running it. Try a complete example →

random.string(...) accepts either a fixed length or a length range:

frl

Rule excerpt: add this to a complete FRL rule before running it. Try a complete example →

Named alphabets are alphanumeric, letters, lower, upper, numbers, numeric, hex, and base64url. You can also pass chars for a custom character set. Use letters: false, numbers: false, casing: "lower", casing: "upper", and exclude when a code needs to avoid confusing characters.

Random string lengths must be from 1 to 256. random.* is allowed in hooks, endpoint bodies, payment events, and helper functions used from those places. It is blocked in allow rules, list guards, and dedupe keys so permissions and repeat-safe endpoints stay stable.

Crypto Helpers

Use crypto.* for hashes, HMAC signatures, and signed webhook checks. Put server-to-server webhooks under /webhooks/ and call their direct /fb-endpoints/webhooks/... URL. These integration routes do not receive browser security challenges, so always verify the provider signature before changing data. Normal visitor form endpoints retain automatic security checks.

backend/index.frl
Rule input (JSON)

Use a complete version 2 rule file. Select a post with “postType” and “action”, or an “endpoint” by name. Saved data, jobs, payments and email need the local server. Dedupe replay protection also needs a site.

Check complete rules or run schemas, permissions, hooks and calculations against the input above. Add excerpts to a complete rule before running.

crypto.hash(...), crypto.sha256(...), crypto.sha384(...), crypto.sha512(...), and crypto.hmac(...) return encoded strings. output can be hex, base64, or base64url. Input encodings can be text, hex, base64, or base64url.

frl

Rule excerpt: add this to a complete FRL rule before running it. Try a complete example →

crypto.verifyHmac(...) accepts:

OptionNotes
algorithmsha1, sha256, sha384, or sha512. Defaults to sha256.
secretSecret key, usually from $secret.
payloadThe signed payload. For webhooks, use $request.rawBody unless the provider documents a different signed string.
signatureSignature header or value to compare.
prefixOptional prefix to strip before comparing, such as sha256=.
paramOptional key to extract from comma/semicolon header values, such as v1.
encodingSignature encoding: hex, base64, or base64url. Defaults to hex.
secretEncodingEncoding for the secret. Defaults to text.
payloadEncodingEncoding for the payload. Defaults to text.

Use crypto.safeEqual(left, right, { encoding }) when you compute a signature manually. Prefer crypto.verifyHmac(...) for webhook guards because it signs and compares in one step.

Continue with Requests and resources reference.