Download the PHP package popphp/pop-crypt without Composer
On this page you can find all versions of the php package popphp/pop-crypt. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download popphp/pop-crypt
More information about popphp/pop-crypt
Files in popphp/pop-crypt
Package pop-crypt
Short Description Pop Crypt Component for Pop PHP Framework
License BSD-3-Clause
Homepage https://github.com/popphp/pop-crypt
Informations about the package pop-crypt
pop-crypt
- Overview
- Install
- Quickstart
- Hashing
- Encryption
Overview
pop-crypt provides various interfaces to assist in encrypting and decrypting secure hashes
or creating and verifying one-way password hashes.
pop-crypt is a component of the Pop PHP Framework.
Install
Install pop-crypt using Composer.
composer require popphp/pop-crypt
Or, require it in your composer.json file
"require": {
"popphp/pop-crypt" : "^3.0.0"
}
Top
Quickstart
Create a password hash:
Create an encrypted value:
Top
Hashing
The standard PHP password hashing algorithms are supported:
PASSWORD_BCRYPTPASSWORD_ARGON2IPASSWORD_ARGON2ID
The PASSWORD_BCRYPT algorithm supports the cost option. The salt has been deprecated as of PHP 8.0.0.
The PASSWORD_ARGON2I and PASSWORD_ARGON2ID algorithms support the following options:
memory_costtime_costthreads
All the algorithms use the standard default values for the options if none are passed.
Top
Encryption
The Encryption classes are built using the openssl extension and its related functions. Supported ciphers are:
aes-128-cbcaes-256-cbcaes-128-gcmaes-256-gcm
It is important to safely store the key or keys used to generate the encrypted data. When correctly paired with their cipher, the encrypted data can successfully be decrypted. However, if the key is incorrect or matched with the wrong cipher, decryption will fail.
Generate Key
A key that matches the chosen cipher can be generated with the following method:
Raw vs Base-64
Methods that manage the key values have an optional $raw parameter.
In the case of generating or getting key values from the encrypter, if $raw is true, then the key value will be
returned as a raw string of bytes. Otherwise, if $raw is false, the key value will be base-64 encoded before it
is returned.
In the case of setting key values or previous key values in the encrypter, if $raw is false, then the key values will
be treated was base-64 encoded values and will be decoded as they are stored in the object. If $raw is true, the
key values will not be processed or decoded in any way.
Previous Keys
In order to preserve legacy keys that have been previously used and rotated out of use, you can load those previous keys to have the encrypter object attempt to use them if the latest key does not work. This provides graceful rotation of keys.
Top