title: Encode password easyadmin v3
body: <p>I have my user that I can manage from my administration panel, I can change the password, but the problem is that in the database it is not encrypted. It is in clear in the database, Save you how I could do it so that it is not anymore? I give you my user entity as well as the crud user And I use the easyadmin v3 and symfony 5 bundle.</p>
  <p>My entity User
  <div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
  
  namespace App\Entity;
  
  use App\Repository\UserRepository;
  use Doctrine\Common\Collections\ArrayCollection;
  use Doctrine\Common\Collections\Collection;
  use Doctrine\ORM\Mapping as ORM;
  use Symfony\Component\Security\Core\User\UserInterface;
  
  
  /**
   * @ORM\Entity(repositoryClass=UserRepository::class)
   */
  class User implements UserInterface
  {
      /**
       * @ORM\Id
       * @ORM\GeneratedValue
       * @ORM\Column(type="integer")
       */
      private $id;
  
      /**
       * @ORM\Column(type="string", length=180, unique=true)
       */
      private $email;
  
      /**
       * @ORM\Column(type="json")
       */
      private $roles = [];
  
      /**
       * @var string The hashed password
       * @ORM\Column(type="string")
       */
      private $password;
  
      /**
       * @ORM\Column(type="string", length=255)
       */
      private $prenom;
  
      /**
       * @ORM\Column(type="string", length=255)
       */
      private $nom;
  
      /**
       * @ORM\Column(type="string", length=255)
       */
      private $telephone;
  
      /**
       * @ORM\Column(type="text", nullable=true)
       */
      private $aPropos;
  
      /**
       * @ORM\Column(type="string", length=255, nullable=true)
       */
      private $facebook;
  
      /**
       * @ORM\OneToMany(targetEntity=Realisation::class, mappedBy="user", orphanRemoval=true)
       */
      private $realisations;
  
      public function __construct()
      {
          $this-&gt;realisations = new ArrayCollection();
      }
  
      public function getId(): ?int
      {
          return $this-&gt;id;
      }
  
      public function getEmail(): ?string
      {
          return $this-&gt;email;
      }
  
      public function setEmail(string $email): self
      {
          $this-&gt;email = $email;
  
          return $this;
      }
  
      /**
       * A visual identifier that represents this user.
       *
       * @see UserInterface
       */
      public function getUsername(): string
      {
          return (string) $this-&gt;email;
      }
  
      /**
       * @see UserInterface
       */
      public function getRoles(): array
      {
          $roles = $this-&gt;roles;
          // guarantee every user at least has ROLE_USER
          $roles[] = 'ROLE_USER';
  
          return array_unique($roles);
      }
  
      public function setRoles(array $roles): self
      {
          $this-&gt;roles = $roles;
  
          return $this;
      }
  
      /**
       * @see UserInterface
       */
      public function getPassword(): string
      {
          return (string) $this-&gt;password;
      }
  
      public function setPassword(string $password): self
      {
          $this-&gt;password = $password;
  
          return $this;
      }
  
      /**
       * Returning a salt is only needed, if you are not using a modern
       * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
       *
       * @see UserInterface
       */
      public function getSalt(): ?string
      {
          return null;
      }
  
      /**
       * @see UserInterface
       */
      public function eraseCredentials()
      {
          // If you store any temporary, sensitive data on the user, clear it here
          // $this-&gt;plainPassword = null;
      }
  
      public function getPrenom(): ?string
      {
          return $this-&gt;prenom;
      }
  
      public function setPrenom(string $prenom): self
      {
          $this-&gt;prenom = $prenom;
  
          return $this;
      }
  
      public function getNom(): ?string
      {
          return $this-&gt;nom;
      }
  
      public function setNom(string $nom): self
      {
          $this-&gt;nom = $nom;
  
          return $this;
      }
  
      public function getTelephone(): ?string
      {
          return $this-&gt;telephone;
      }
  
      public function setTelephone(string $telephone): self
      {
          $this-&gt;telephone = $telephone;
  
          return $this;
      }
  
      public function getAPropos(): ?string
      {
          return $this-&gt;aPropos;
      }
  
      public function setAPropos(?string $aPropos): self
      {
          $this-&gt;aPropos = $aPropos;
  
          return $this;
      }
  
      public function getFacebook(): ?string
      {
          return $this-&gt;facebook;
      }
  
      public function setFacebook(?string $facebook): self
      {
          $this-&gt;facebook = $facebook;
  
          return $this;
      }
  
      /**
       * @return Collection|Realisation[]
       */
      public function getRealisations(): Collection
      {
          return $this-&gt;realisations;
      }
  
      public function addRealisation(Realisation $realisation): self
      {
          if (!$this-&gt;realisations-&gt;contains($realisation)) {
              $this-&gt;realisations[] = $realisation;
              $realisation-&gt;setUser($this);
          }
  
          return $this;
      }
  
      public function removeRealisation(Realisation $realisation): self
      {
          if ($this-&gt;realisations-&gt;removeElement($realisation)) {
              // set the owning side to null (unless already changed)
              if ($realisation-&gt;getUser() === $this) {
                  $realisation-&gt;setUser(null);
              }
          }
  
          return $this;
      }
      public function __toString()
      {
          return $this-&gt;nom;
      }
      /* public function __toString(){
           return $this-&gt;nom;
       }*/
  }</code></pre>
  </div>
  </div>
  </p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
  
  namespace App\Controller\Admin;
  
  use App\Entity\User;
  use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
  use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField;
  use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
  
  class UserCrudController extends AbstractCrudController
  {
      public static function getEntityFqcn(): string
      {
          return User::class;
      }
  
  
      public function configureFields(string $pageName): iterable
      {
          return [
              IntegerField::new('id','ID')-&gt;onlyOnIndex(),
              TextField::new('email'),
              TextField::new('password'),
              TextField::new('nom'),
              TextField::new('telephone'),
              TextField::new('aPropos'),
              TextField::new('facebook'),
          ];
      }
  
  
  }</code></pre>
  </div>
  </div>
  </p>