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

3 Answers

0 votes
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
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
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 1.1k views
+1 vote
1 answer 1.8k views
0 votes
1 answer 1.9k views
+1 vote
2 answers 9.1k views
asked Jan 30, 2018 in Frameworks by Doumeki (480 points)
+1 vote
1 answer 1.8k views
0 votes
1 answer 7.4k views
...