0 votes
925 views
asked in Magento by
How to Encrypt and decrypt information in Magento? Is there an inbuilt functionality to do this?

3 Answers

0 votes
answered by

Encrypting a string in Magneto is really really. Magento will use the encryption key specified in the local.xml file:

<?php
$encryptedData = Mage::helper('core')->encrypt("This will be encrypted");

There is one problem that you may encounter that can be a little bit problematic but there is an easy work around. The encryption process will strip out non-printing characters or character it does not recognise. Easiest way to get about this is to base64 encode what you are about to encrypt:

<?php
$encryptedData = Mage::helper('core')->encrypt(base64_encode("\n\rI start with a carriage return"));

Decrypting is just as easy:

<?php
$decyptedData = Mage::helper('core')->decrypt($encryptedData);

Remember to base64_decode after decryption if you did base64 encode before encryption:

<?php
$decyptedData = base64_decode(Mage::helper('core')->decrypt($encryptedData));
0 votes
answered by
NO! Never ever do this. Take your hands out.

You destroy the whole logic in mysql, because you can't filter or order.
0 votes
answered by
Maybe you are talking about the SSL thing?

If this is already a running site with data populated in the database, I wont recommend doing something like this. This is likely to create issues with the old data unless you do the encryption manually on already happened entries.

Related questions

+2 votes
0 answers 475 views
+1 vote
1 answer 662 views
0 votes
1 answer 443 views
+1 vote
2 answers 2.4k views
+1 vote
1 answer 645 views
0 votes
1 answer 2.9k views
...