0

I have added column password_custom in table eav_attribute customer. I want to encode the input data. How do I do that? I followed the instructions here https://vacademyideas.com/blog/how-to-add-custom-field-in-magento-2-registration-form/

result https://i.stack.imgur.com/77Rmz.png desired result

admin@123 ==> LAdsuiwqebwquihdsa121iydsai

Input data must be encrypted.

1

1 Answer 1

0

To convert the password, you can use this code.

<?php

use Magento\Framework\Encryption\EncryptorInterface;

public function __construct(EncryptorInterface $encryptor) 
{
    $this->encryptor = $encryptor;
}

public function encryptPassword($your_password)
{
    return $this->encryptor->encrypt($your_password);
}

public function decryptPassword($your_password)
{
    return $this->encryptor->decrypt($your_password);
}
2
  • where is it used in observer or plugin? i know this function is in Magento but when i save password in attribute where are they encrypted or is it in InstallData.php Dec 27, 2021 at 9:01
  • You can use this in place where you want to save the data into that field. Dec 27, 2021 at 9:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.