Download the PHP package units/password without Composer

On this page you can find all versions of the php package units/password. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package password

Units — Password

Store passwords so they can be checked, and never read back.

PHP's own password_hash(), password_verify() and password_needs_rehash(). The cryptography is the one your PHP was already built and tested with.

The words

Password hash — one way, and slow on purpose, so guessing is expensive.

Salt — random input inside the hash, so the same password gives a different result every time. Automatic here, and the reason one cracked password does not open every account that shares it.

Pepper — a secret mixed into the password before hashing, kept out of the database. Not here: it is your secret and your decision.

Cost — how much work the hash does. Higher is slower, and stronger.

Storing

One line of text, carrying its own algorithm, its own settings and its own salt. Store it in a VARCHAR(255).

The same password gives a different string every time. Never store a constant, never compare two stored values, never expect them to match.

Checking

The only way to check. It reads the algorithm out of the stored value, not out of your configuration, so one unit checks today's Argon2id hashes and 2019's bcrypt hashes alike.

verify() never throws. An empty, truncated or nonsense value is simply false:

Upgrading stored passwords

Settings get stronger over time. You can only re-hash while the password is in hand — right after a successful check:

Nobody resets anything. Each user is upgraded the next time they sign in.

What a stored hash says about itself

The setting that does nothing

Settings go to PHP unchanged, so a setting from the wrong algorithm is silently ignored — by PHP, and therefore by you:

cost is bcrypt's. Argon2id has none, so that is not a stronger Argon2id — it is an ordinary one, and needsRehash() will not notice either. Ask the hash instead of trusting the request:

Argon2id takes memory_cost, time_cost, threads. bcrypt takes cost.

Prefer Argon2id

Argon2id is optional in PHP, so the unit refuses an algorithm this build cannot run — when you configure it, not at a signup:

Use bcrypt when something else has to read the value.

The pepper is yours

A pepper never enters the database, so stealing the table is not enough on its own. Where it comes from, how it rotates, whether you want one — your call, not a library's. This unit hashes what it is handed.

Not the hasher

units/hasher fingerprints data: fast, always the same answer. This protects credentials: slow, never the same answer. Each refuses to be the other — Password has no hmac() or sha256(), Hasher has no needsRehash().

It knows its version

Reference

Method Gives you
create(['algorithm' => …, 'options' => …, 'dna' => …]) a password unit
hash($password) PasswordResult — store ->hash
verify($password, $stored) bool, never throws
needsRehash($stored) bool — is this behind the settings
algorithms() supports($name) what this PHP can actually run
algorithm() options() dna() whoami() help() itself

PasswordResult carries hash, algorithm and options. It is immutable, and (string) $result is the stored value.

MIT · tests: composer test


All versions of password with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
patterns/unit Version ^1.0.1
patterns/value-object Version ^2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package units/password contains the following files

Loading the files please wait ...