Using character arrays to save passwords is better than saving passwords using string

Source: Internet
Author: User

In Java, it is better to save a password using a character array than to save the password using string.

Two reasons:

  1. It is difficult to purge from memory.
    String is a non-mutable object that is placed in a string buffer to facilitate reuse, so it may be retained in memory for a long time.
    Any person with access to the memory can easily see the plaintext password
    Of course, the plaintext password should not be used at all.
  2. Java provides the GetPassword () method of the JPasswordField component
    This is specially prepared for the password, don't you? Don't be lazy.
  3. At a time you don't know, it could be leaked somewhere else.
    such as the log. May 2018 Twitter Hundreds of millions of user plaintext password disclosure (see here: 330 million user password suspect, Twitter a major security vulnerability), is an example

Using character arrays to save passwords is better than saving passwords using string

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.