Giter Site home page Giter Site logo

bcrypt-php-class's Introduction

Bcrypt PHP Class

This library is intended to work with PHP Password Hashing Functions

Requirements

Requires PHP >= 5.5

Usage

Creating Password Hashes

To create a password hash from a password:

    $hash = Bcrypt::hash($password);

Checking Password match Hashes

    $hash = Bcrypt::check($password, $hash);

Options

Optionally you can add the algorithm to use, the following algorithms are currently supported (you must define one of this):

  • PASSWORD_DEFAULT - Use the bcrypt algorithm (default as of PHP 5.5.0). Note that this constant is designed to change over time as new and stronger algorithms are added to PHP. For that reason, the length of the result from using this identifier can change over time. Therefore, it is recommended to store the result in a database column that can expand beyond 60 characters (255 characters would be a good choice).
  • PASSWORD_BCRYPT - Use the CRYPT_BLOWFISH algorithm to create the hash. This will produce a standard crypt() compatible hash using the "$2y$" identifier. The result will always be a 60 character string, or FALSE on failure.

You can add the algorithmic cost parameter, 10 is a good baseline cost, but you may want to consider increasing it depending on your hardware. The cost can range from 4 to 31.

Benchmark your server

To determine how high of a cost you can afford try this:

    $hash = Bcrypt::appropriateCost();

This function calculates how much cost supports your server. You can add some options:

  • timeTarget: max time execution of password_hash function
  • startCost: the initial value of the cost

bcrypt-php-class's People

Contributors

vctrmg avatar

Watchers

 avatar

Forkers

lucasnpinheiro

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.