💾 Archived View for bad-gateway.smol.pub › 20220308 captured on 2024-08-18 at 20:19:04. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2022-04-28)

-=-=-=-=-=-=-

2022-03-08: Do this

public static final String ALGORITHM = “PBKDF2WithHmacSHA512”;
public static final int ITERATION_COUNT = 10000;
public static final int KEY_LENGTH = 20; /* Bytes. 160 bit */
public static final int SALT_LENGTH = 4; /* Bytes. 32 bit */

public void store(String user, String password) {
  byte[] salt = new byte[this.SALT_LENGTH];
  SecureRandom.getInstanceStrong().nextBytes(salt);
  SecretKeyFactory kf = SecretKeyFactory.getInstance(this.ALGORITHM);
  PBEKeySpec spec = new PBEKeySpec(password.toCharArray(), salt, this.ITERATION_COUNT, this.KEY_LENGTH);
  byte[] hash = kf.generateSecret(spec).getEnocoded();
  this.store.put(user, new Entry(hash, salt));
}

7 points easy no?