You should not trim the password. If you do not want to accept passwords with spaces then a password containing spaces should not be accepted.
- Should you allow spaces in passwords?
- Can a passphrase include spaces?
- Does Google allow spaces in passwords?
Should you allow spaces in passwords?
Absolutely! Using spaces in passwords is an excellent idea, because it significantly improves the security (strength) of your passwords. It helps to protect your accounts from attackers who might be trying to guess your passwords, crack them, or employ brute forcing in order to compromise your accounts.
Can a passphrase include spaces?
Best practices that users can incorporate when creating strong passphrases include the following: Use an easy to remember but uncommon group of four to eight words. Add spaces within and between words.
Does Google allow spaces in passwords?
By Google's rating standard, including whitespace improves the quality/strength of a password. Improves the strength, but may break applications - white space is often used to delimit parameters. The strength isn't entirely relevant to the question of whether you should allow them.