You can Encrypt or Decrypt any string using Magento 2 with native interface functionality.
You can encrypt or decrypt password or credit card data or any value you need to encrypt using Magento\Framework\Encryption\EncryptorInterface interface.
Example, You can encrypt the password with below way,
