Download the PHP package miladrahimi/phpcrypt without Composer
On this page you can find all versions of the php package miladrahimi/phpcrypt. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download miladrahimi/phpcrypt
More information about miladrahimi/phpcrypt
Files in miladrahimi/phpcrypt
Package phpcrypt
Short Description Encryption, decryption, and hashing tools for PHP projects
License MIT
Homepage https://github.com/miladrahimi/phpcrypt
Informations about the package phpcrypt
PhpCrypt
PhpCrypt is a package for encryption, decryption, and hashing data in PHP projects. It provides an easy-to-use and fluent interface.
Features:
- Symmetric encryption/decryption using AES and other symmetric methods.
- Asymmetric encryption/decryption using the RSA method.
- Hashing and verifying data (e.g. passwords) using the BCrypt method.
Versions
- v5.x.x
- v4.x.x
- v3.x.x (Unsupported)
- v2.x.x (Unsupported)
- v1.x.x (Unsupported)
Installation
Install Composer and run the following command in your project's root directory:
Symmetric Encryption
This example shows how to encrypt and decrypt data using symmetric algorithms like AES.
It generates a random key and uses aes-256-cbc
method for encrypting/decrypting data.
Custom Key
If you have already a key, you can use your own key like this:
The method generateKey
can help you to generate a new random key.
See the snippet below.
Custom Methods
In default, The Symmetric
class uses aes-256-cbc
method to encrypt/decrypt data.
You can use your preferred method as well.
See the following example.
Supported Methods
If you want to know which methods do your installed OpenSSL extension support, see the snippet below:
RSA Encryption
RSA is a popular asymmetric encryption/decryption algorithm. The examples below illustrate how to encrypt/decrypt data using the RSA algorithm.
Encryption with private key
In this example, we encrypt data with a private key and decrypt it with the related public key.
Encryption with public key
In this example, we encrypt data with a public key and decrypt it with the related private key.
Base64 Encoding
In default, the encrypted data returned by PrivateRsa::encrypt()
and PublicRsa::encrypt()
methods will be Base64 encoded.
You can disable this encoding like the example below.
Hashing
This example shows how to hash data and verify it.
Error Handling
The Symmetric
, PrivateRsa
, PublicRsa
, and Hash
classes may throw these exceptions:
EncryptionException
: When it cannot encrypt data.DecryptionException
: When it cannot decrypt data.HashingException
: When it cannot hash data.MethodNotSupportedException
: When the passed encryption method to theSymmetric
class is not supported.InvalidKeyException
: When the passed key toPrivateRsa
orPublicRsa
classes is not valid.
License
PhpCrypt is initially created by Milad Rahimi and released under the MIT License.
All versions of phpcrypt with dependencies
ext-openssl Version *