On this page
Sanitize data with Scrambler
You are browsing documentation for an older version of Drupal, which is not supported any longer, and the information may not be correct. See current documentation for Contributed modules
The Scrambler module helps you prevent exposing sensitive information from the database.
Please note that you should never use/enable Scrambler in a production environment!.
In case of accidental execution of the scrambling procedure there is no way back. Your data will then be damaged.
The Scrambler module is an API that helps you to prevent exposing sensitive
information from the database. It also contains the Scrambler Field submodule
which makes it able to administer which scramble methods to apply per field.
For a full description of the module, visit the project page.
Creating custom implementations
/**
* Implements hook_scrambler_api().
*/
function scrambler_example_scrambler_api() {
// Define your module name.
$params['scrambler_example'] = array(
// Give a unique machine name for your scrambling group.
'shuffle_words_for_title' => array(
// Define base table where these fields are located.
'base_table' => 'scrambler_example',
// Define the id of the base table.
'id' => 'sid',
// Define field names.
'fields' => array('title'),
// Define a scramble method from the scrambler API.
'method' => SCRAMBLER_METHOD_SHUFFLE_WORDS,
),
// Give a unique machine name for your scrambling group.
'custom_method_for_teaser' => array(
// Define base table where these fields are located.
'base_table' => 'scrambler_example',
// Define the id of the base table.
'id' => 'sid',
// Define field names.
'fields' => array('teaser'),
// Define your custom scrambling method.
'method' => 'custom_scrambling',
),
);
return $params;
}
/**
* Implements hook_scrambler_methods().
*/
function scrambler_example_scrambler_methods() {
return array('custom_scrambling' => 'Custom scrambling (scrambler_example module)');
}
/**
* Custom scrambling method by the scrambler_example module.
*
* @param string $data
* Input data to scramble.
*
* @return string
* Returns the scrambled string.
*/
function _scrambler_example_method_custom_scrambling(&$data) {
// Manipulate the $data parameter in which way you think is necessary.
return str_replace('e', 'x', str_replace('a', 'y', $data));
}
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion