Hi,

I'm trying to encrypt profile fields but I can't make it work.

I have installed Encrypt with configuration:

Encryption method settings -> Mcrypt AES (CBC Mode)
Key Provider -> Drupal encrypt_drupal_variable_key variable

settings.php -> $conf['encrypt_drupal_variable_key'] = 'u1xnyr5zFzGj92do6gZHL72IQjmF1Omqepmba7FwJNI';

I always get: Encryption failed because the key is not the right size, no matter the size of encrypt_drupal_variable_key I use. Could I have one working example of this key?

Thank you!

Comments

jeepster created an issue. See original summary.

rlhawk’s picture

It looks as though your key is Base64-encoded, but you're missing a trailing "=".

jeepster’s picture

thanks, @rlhawk

where am i missing this "=" ???

$conf['encrypt_drupal_variable_key'] = 'u1xnyr5zFzGj92do6gZHL72IQjmF1Omqepmba7FwJNI';

jeepster’s picture

In Additional Key Provider Settings I selected Variable contents; I don't know exactly what it means bit if I select Base64 decode I have this error:

Data too long for column 'field_first_name_value' at row 1 :(

rlhawk’s picture

The "=" should be the last character of the key.

If the database column can't support the length of the encrypted field value, you will need to alter the column definition.

jeepster’s picture

You're right, now I have ok the key but I would have to alter the column definition.

jeepster’s picture

Changing the database column worked for encryption but now I have this error in decryption:
Exception: Decryption failed because the HMAC could not be validated

Any ideas? Thanks!

jeepster’s picture

Ok, Exception: Decryption failed because the HMAC could not be validated shows up when there not encrypted text to decrypt.

Anyway, decrypt does not work either.

I have this field_first_name_value: a:6:{s:4:"text";s:128:"X1b6pVhtryS65NP2SbWCNcleYiwExkDPu31ybzepYUxbmmEjZ+TfEBeyeMUYq5I7xUi/mDCAEcjuCLyjcL3f87wzYXtajwe1/Bt1Hv9WPDHwWKyw4YsZp1QUW8kpHuNQ";s:6:"method";s:14:"mcrypt_aes_cbc";s:12:"key_provider";s:15:"drupal_variable";s:7:"options";a:0:{}s:15:"method_settings";s:0:"";s:17:"provider_settings";a:1:{s:6:"method";s:13:"base64_decode";}}

And decrypt (this) returns the same...

jeepster’s picture

My fault, module is decrypting ok. Thanks @rlhawk for your help :)

rlhawk’s picture

Status: Active » Closed (works as designed)
Cellar Door’s picture

Just catching up on this ticket - One thing to caution is you've posted the key to the public forum here so you'll want to be sure not to use this key again (hopefully it's just an example key). If you want, Lockr can create cryptographically secure keys to help you out or you can roll it with a new random cryptographic key rotator.

Just wanted to make sure your data is safe and this isn't a key used anywhere sensitive.

jeepster’s picture

Yes, @Cellar Door, it was an example key, I have a new (hopefully secure) key.

Thank you very much for your concern.

jeepster’s picture

@rlhawk, may I ask you about Encrypt User? I saw it is in sandbox and it would be perfect for my project but I have doubts, are the bugs already fixed? is it working ok?

thank you!

rlhawk’s picture

Hmm, I'm actually not sure about that. I wouldn't feel comfortable recommending it, without a quick review.

jeepster’s picture

ok, thanks, @rlhawk!!