爲何密碼比字符串更喜歡char []? - Why is char[] preferred over String for passwords?

問題:

In Swing, the password field has a getPassword() (returns char[] ) method instead of the usual getText() (returns String ) method. 在Swing中,密碼字段具備getPassword() (返回char[] )方法,而不是一般的getText() (返回String )方法。 Similarly, I have come across a suggestion not to use String to handle passwords. 一樣,我遇到了不使用String處理密碼的建議。 安全

Why does String pose a threat to security when it comes to passwords? 爲何在密碼方面String會對安全構成威脅? It feels inconvenient to use char[] . 使用char[]感受很不方便。 spa


解決方案:

參考一: https://stackoom.com/question/bGQd/爲何密碼比字符串更喜歡char
參考二: https://oldbug.net/q/bGQd/Why-is-char-preferred-over-String-for-passwords
相關文章
相關標籤/搜索