Should I trim spaces in a password field

后端 未结 8 654
南旧
南旧 2021-01-01 12:17

Just wondering.

We usually trim a user name in various forms in our ASP.Net application, whats the best practices for password fields.

i.e. should we remove

8条回答
  •  借酒劲吻你
    2021-01-01 12:43

    If you use the same trimming method when inputting in the db as you use when you select to test the password, the user's password will still work just fine.

    There is of course a slight reduction of quality for that (very rare) user who choose to use white space in the beginning or end of her password.

    Spaces inside passwords should never be a problem, tho.

    In summary: I have not come across any good reason not to do a simple trim() for any input from web forms and the alike, passwords or not. The benefits, however, far outweighs the slight cost mentioned above.

提交回复
热议问题