Skip to content

Global Helpers

obfuscateParam()

obfuscateParam() — returns string

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

Obfuscates a value. Typically used for hiding primary key values when passed along in the URL.

NameTypeRequiredDefaultDescription
paramanyyes—The value to obfuscate.
// 1. Obfuscate a primary key value before including it in a URL
obfuscatedId = obfuscateParam(99);
// obfuscatedId -> "a3f6c1" (an obfuscated hex string)

// 2. Use an obfuscated key in a generated URL to hide the real record ID
params.userKey = obfuscateParam(model("User").findOne().key());
redirectTo(route="userProfile", key=params.userKey);

// 3. Reverse the obfuscation with deobfuscateParam to get the original value back
obfuscated = obfuscateParam(42);
original = deobfuscateParam(obfuscated);
// original -> "42"