Encrypting a Private Message

198 views Asked by At

I am using both the Private Message module and the Encrypt modules. I can of course create a field which is encrypted, but it looks like I must alter the PM module since its storage in the database is not encrypted. Isn't exactly private then is it. Permissions are not enough to make it a Private Message.

I assume I will need to add the Encrypt code directly to the module itself. Does anyone have any idea where I would add it and how?

Thanks

2

There are 2 answers

0
Felix Eve On

I've done something similar before to store encrypted images directly in the DB (for passport photos).

I've just had a quick look at the private messages module and it looks like you'll need to modify the main .module file. Search though it for db_insert. At around line 1836 is the bit that saves the message to the db.

If you add:

$message->body = encrypt($message->body);

before the line:

$args['body'] = $message->body;

Then that will handle the encryption.

Then you need to find where it gets back out the DB and put the decryption function in there.

1
Amrit On

The module is named "private messages" because the messages are private between the sender & recipient, no one else can see the messages.

If you want to encrypt the database, then you can directly use the database API hooks. You will also have to alter the schema of private messages module I believe.

For HTTPS you can use https://drupal.org/project/securepages

And for encrypting the form submitted data, you can go with http://www.jcryption.org/ or even more interesting http://crypto.stanford.edu/sjcl/