BCrypt Class

Provides static methods used to encrypt passwords. The encryption is "one-way" meaning that passwords can be encrypted but not decrypted. Although you cannot decrypt a password, you can still validate a password using the checkpw() method. Example usage:
    public class User {
        private String password;

        public boolean authenticate(String password){
            return BCrypt.checkpw(password, this.password);
        }

        public void setPassword(String password){
            this.password = BCrypt.hashpw(password, BCrypt.gensalt());
        }
    }  
This class was originally developed by Damien Miller and is based on Bruce Schneier's Blowfish cipher.

Constructors

There are no public constructors.

Static Methods

hashpw( String password ) returns String
hashpw( String password, String salt ) returns String
Returns a BCrypt hashed password
passwordthe password to hash
saltthe salt to hash with (perhaps generated using BCrypt.gensalt)
hashpw( String password, Salt salt ) returns String
hasSalt( String password ) returns boolean
Returns true if a given string starts with a valid BCrypt hash
gensalt( int log_rounds, SecureRandom random ) returns String
Generate a salt for use with the BCrypt.hashpw() method
log_roundsthe log2 of the number of rounds of hashing to apply - the work factor therefore increases as 2**log_rounds.
randoman instance of SecureRandom to use
gensalt( int log_rounds ) returns String
Generate a salt for use with the BCrypt.hashpw() method
log_roundsthe log2 of the number of rounds of hashing to apply - the work factor therefore increases as 2**log_rounds.
gensalt( ) returns String
Generate a salt for use with the BCrypt.hashpw() method, selecting a reasonable default for the number of hashing rounds to apply
checkpw( String plaintext, String hashed ) returns boolean
Returns true if a plain-text password matches a BCrypt hashed password

Public Classes