### Question:
BCrypt { @Nonnull public static String hashpw (@Nonnull final String sPassword, @Nonnull final String sSalt) { if (sSalt.charAt (0) != '$' || sSalt.charAt (1) != '2') throw new IllegalArgumentException ("Invalid salt version"); char minor = (char) 0; int off; if (sSalt.charAt (2) == '$') off = 3; else { minor = sSalt.charAt (2); if (minor != 'a' || sSalt.charAt (3) != '$') throw new IllegalArgumentException ("Invalid salt revision"); off = 4; } if (sSalt.charAt (off + 2) > '$') throw new IllegalArgumentException ("Missing salt rounds"); final int rounds = Integer.parseInt (sSalt.substring (off, off + 2)); final String sRealSalt = sSalt.substring (off + 3, off + 25); final byte [] aPasswordb = (sPassword + (minor >= 'a' ? "\000" : "")).getBytes (StandardCharsets.UTF_8); final byte [] aSaltb = _decode_base64 (sRealSalt, BCRYPT_SALT_LEN); final BCrypt aBCrypt = new BCrypt (); final byte [] hashed = aBCrypt.crypt_raw (aPasswordb, aSaltb, rounds, BF_CRYPT_CIPHERTEXT.clone ()); final StringBuilder aSB = new StringBuilder (); aSB.append ("$2"); if (minor >= 'a') aSB.append (minor); aSB.append ('$'); if (rounds < 10) aSB.append ('0'); else if (rounds > 30) throw new IllegalArgumentException ("rounds exceeds maximum (30)"); aSB.append (Integer.toString (rounds)); aSB.append ('$'); aSB.append (_encode_base64 (aSaltb, aSaltb.length)); aSB.append (_encode_base64 (hashed, BF_CRYPT_CIPHERTEXT.length * 4 - 1)); return aSB.toString (); }  @Nonnull byte [] crypt_raw(final byte [] password, final byte [] salt, final int nLogRounds, final int [] cdata); @Nonnull static String hashpw(@Nonnull final String sPassword, @Nonnull final String sSalt); @Nonnull static String gensalt(@Nonnegative final int nLogRounds, @Nonnull final SecureRandom aRandom); @Nonnull static String gensalt(@Nonnegative final int log_rounds); @Nonnull static String gensalt(); static boolean checkpw(@Nonnull final String sPlaintext, @Nonnull final String sHashed); static final int GENSALT_DEFAULT_LOG2_ROUNDS; static final int BCRYPT_SALT_LEN; }### Answer:
@Test public void testHashpw () { LOGGER.info ("BCrypt.hashpw(): "); for (final String [] test_vector : test_vectors) { final String plain = test_vector[0]; final String salt = test_vector[1]; final String expected = test_vector[2]; final String hashed = BCrypt.hashpw (plain, salt); assertEquals (hashed, expected); LOGGER.info ("."); } LOGGER.info (""); }