Reputation: 54
I am creating magento 2 custom module, where I am getting some data using API call. I need to store that data in my custom table. Before storage I need to encrypt that data. I think there is default encrypt function for that. I have used Mage::helper('Mage_Core_Helper_Data')->encrypt($value)
. But no success.
Upvotes: 0
Views: 5700
Reputation: 1907
You can use it this way:
use Magento\Framework\Encryption\EncryptorInterface as Encryptor;
in the construct function :
$this->encryptor = $encryptor;
then call encrypt function to encrypt:
$encrypt = $this->encryptor->encrypt($data);
and to decrypt:
$decrypt = $this->encryptor->decrypt($data);
Upvotes: 1