Skip to content

Global Helpers

obfuscateParam()

obfuscateParam() — returns string

Available in: controller, model, test, migrator, migration, tabledefinition Category: Miscellaneous Functions

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.

NameTypeRequiredDefaultDescription
paramanyyesThe value to obfuscate.
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))#