I'd like to store data securely in the database of my site which is a D6 based OpenAtrium install. To this end, I prettymuch just grabbed the text module from CCK (since I'm not releasing this as my own module) and then enabled the Encrypt module and added "encrypt()" and "decrypt()" around what I thought were the appropriate variables.
I have no issue with decrypting the data, but encrypting it seems to be a bit of a battle.
Long story short, I found that CCK modules don't innately have a way for you to alter your content from the form before saving it. I could do a hook_nodeapi, but I couldn't find a function that would let me go query a field and determine what field type it is.
Has anyone encountered this or have an idea of what could be the issue?
Thanks,
--James

Comments
Got it!
I had to add the following to get it working:
function encrypted_text_nodeapi(&$node, $op) {switch ($op) {
case 'presave':
$fields = content_fields(null,$node->type);
foreach ($fields as $field_name => $field_data){
if ($field_data['type'] == 'encrypted_text') {
if (is_array($node->$field_name)) {
// Had to do this for some weirdness
$delta = 0;
$instances = $node->$field_name;
foreach ($instances as $value) {
if (!is_empty($value['value'])) {
$value['value'] = encrypt($value['value']);
$instances[$delta] = $value;
}
$delta++;
}
$node->$field_name = $instances;
} else {
// This part is untested
$node->$field_name['value'] = encrypt($node->$field_name['value']);
}
}
}
break;
}
}
Once I did all that (for some reason using delta in $node->$field_name[$delta] was returning nothing) it started working.
--James