public class Blowfish extends Object
加解密
| Modifier and Type | Field and Description |
|---|---|
static int |
MAX_LOG_ROUNDS |
static int |
MIN_LOG_ROUNDS |
| Constructor and Description |
|---|
Blowfish() |
Blowfish(int strength) |
Blowfish(int strength,
SecureRandom random) |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
checkpw(String plaintext,
String hashed)
Check that a plaintext password matches a previously hashed first
|
String |
encode(CharSequence rawPassword) |
static String |
gensalt()
Generate a salt for use with the Blowfish.hashpw() method, selecting a reasonable
default for the number of hashing rounds to apply
|
static String |
gensalt(int log_rounds)
Generate a salt for use with the Blowfish.hashpw() method
|
static String |
gensalt(int log_rounds,
SecureRandom random)
Generate a salt for use with the Blowfish.hashpw() method
|
static String |
hashpw(String password,
String salt)
Hash a password using the OpenBSD bcrypt scheme
|
boolean |
matches(CharSequence rawPassword,
String encodedPassword) |
public static final int MIN_LOG_ROUNDS
public static final int MAX_LOG_ROUNDS
public Blowfish()
public Blowfish(int strength)
strength - the log rounds to use, between 4 and 31public Blowfish(int strength,
SecureRandom random)
strength - the log rounds to use, between 4 and 31random - the secure random instance to usepublic static String hashpw(String password, String salt) throws IllegalArgumentException
password - the password to hashsalt - the salt to hash with (perhaps generated using Blowfish.gensalt)IllegalArgumentException - if invalid salt is passedpublic static String gensalt(int log_rounds, SecureRandom random)
log_rounds - the log2 of the number of rounds of hashing to apply - the work
factor therefore increases as 2**log_rounds. Minimum 4, maximum 31.random - an instance of SecureRandom to usepublic static String gensalt(int log_rounds)
log_rounds - the log2 of the number of rounds of hashing to apply - the work
factor therefore increases as 2**log_rounds. Minimum 4, maximum 31.public static String gensalt()
public static boolean checkpw(String plaintext, String hashed)
plaintext - the plaintext password to verifyhashed - the previously-hashed passwordpublic String encode(CharSequence rawPassword)
public boolean matches(CharSequence rawPassword, String encodedPassword)
Copyright © 2019. All rights reserved.