Answer is partially incorrect / misleading.
Issues:
Passwords in Salesforce are never handled directly – you cannot store or encrypt user passwords in Apex or custom objects.
Masking passwords or showing last characters is not recommended for standard Salesforce authentication flows.
Encryption advice applies to API keys or tokens, not user passwords.
Correct Guidance / Suggested Rewrite:
“To implement password change functionality securely:
Use Salesforce-managed authentication: Rely on standard Salesforce password change flows or SSO/OAuth mechanisms.
Never echo passwords: Do not display, log, or store passwords anywhere in your app.
Secure token handling: For API tokens or authentication secrets, store them in protected custom settings, encrypted fields, or Named Credentials.
Sanitize inputs: Ensure all user input is validated and never injected into UI or logs.
Follow MFA and secure login best practices: Enforce multi-factor authentication and secure transport (HTTPS/TLS).”
This aligns with Salesforce security policies and avoids unsafe practices.