-- Leo's gemini proxy

-- Connecting to bad-gateway.smol.pub:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

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?

-- Response ended

-- Page fetched on Sat May 4 03:23:19 2024