💾 Archived View for bad-gateway.smol.pub › 20220308 captured on 2022-04-29 at 12:20:16. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2022-04-28)
-=-=-=-=-=-=-
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)); }