Global Helpers
obfuscateParam()
Signature
Section titled “Signature”obfuscateParam() — returns string
Available in: controller, model, test, migrator, migration, tabledefinition
Category: Miscellaneous Functions
Description
Section titled “Description”Obfuscates a value, typically used to hide sensitive information like primary key IDs when passing them in URLs. This helps prevent users from easily guessing sequential IDs or sensitive values.
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
param | any | yes | — | The value to obfuscate. |
Examples
Section titled “Examples”1. Obfuscate a numeric primary key
// Primary key value
id = 99;
// Obfuscate it before sending in the URL
obfuscatedId = obfuscateParam(id);
writeOutput(obfuscatedId);
2. Obfuscate a string value
// Obfuscate an email address
email = "user@example.com";
obfuscatedEmail = obfuscateParam(email);
writeOutput(obfuscatedEmail);
3. Use obfuscated value in a link
// Pass obfuscated ID in a linkTo helper
userId = 42;
#linkTo(text="View Profile", controller="user", action="profile", key=obfuscateParam(userId))#