https://github.com/lorddashme/php-cryptor
A PHP package wrapper for cryptography functions.
https://github.com/lorddashme/php-cryptor
cryptography-functions encryption hash php php-library security
Last synced: about 1 year ago
JSON representation
A PHP package wrapper for cryptography functions.
- Host: GitHub
- URL: https://github.com/lorddashme/php-cryptor
- Owner: LordDashMe
- License: mit
- Created: 2018-01-03T04:25:40.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-04-01T16:08:51.000Z (over 3 years ago)
- Last Synced: 2025-04-10T20:22:24.174Z (about 1 year ago)
- Topics: cryptography-functions, encryption, hash, php, php-library, security
- Language: PHP
- Homepage:
- Size: 35.2 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PHP Cryptor
A package wrapper for PHP cryptography functions.
[](https://packagist.org/packages/lorddashme/php-cryptor) [](https://php.net/) [](https://coveralls.io/github/LordDashMe/php-cryptor?branch=master)
## Requirement(s)
- PHP version from 5.6.* up to latest.
## Install
- It is advice to install the package via Composer. Use the command below to install the package:
```txt
composer require lorddashme/php-cryptor
```
## Usage
### List of Wrapped Class Extensions
| Class | Description |
| ----- | ----------- |
|
|
|
| [OpenSSL](#openssl-class) | Use this extension to encrypt or decrypt a content. |
| [PasswordHashing](#password-hashing-class) | Use this extension to hash a password content. |
#### OpenSSL Class
- To encrypt plain text.
```php
cipherMethod(
OpenSSL::CIPHER_METHOD_AES256
);
// Provide the key that will be using to encrypt the given content.
$openssl->key('password');
// The plain text that will be process to encrypt.
$openssl->content('this is the plain text');
// Execute the encryption process.
$openssl->encrypt();
// Output the processed content.
$openssl->get(); // echo "YToyOntzOjc6ImNvbnRlbnQiO3M6MzI6..."
```
- To decrypt encrypted content.
```php
cipherMethod(
OpenSSL::CIPHER_METHOD_AES256
);
// Provide the key that will be using to encrypt the given content.
$openssl->key('password');
// The encrypted content that will be process to decrypt.
$openssl->content('YToyOntzOjc6ImNvbnRlbnQiO3M6MzI6...');
// Execute the decryption process.
$openssl->decrypt();
// Output the processed content.
$openssl->get(); // echo "this is the plain text"
```
#### Password Hashing Class
- To hash the content.
```php
algorithm(
PasswordHashing::ALGO_PASSWORD_DEFAULT
);
// Execute the hashing process.
$hashing->hash('Need to be hash');
// Output the processed content.
$hashing->get(); // echo "$2y$10$cwzwDA.wXJitJMPQt9ogDe5rf46dASXh8r5DPIyH1Up3HhhROcFti"
```
- To re-hash the content.
```php
algorithm(
PasswordHashing::ALGO_PASSWORD_DEFAULT
);
// Execute the re-hashing process.
$hashing->rehash('Need to be hash', '$2y$10$cwzwDA.wXJitJMPQt9ogDe5rf46dASXh8r5DPIyH1Up3HhhROcFti');
// Output the processed content.
$hashing->get(); // echo "$2y$10$cwzwDA.wXJitJMPQt9ogDe5rf..."
```
- To get the info of the hashed content.
```php
getInfo('$2y$10$cwzwDA.wXJitJMPQt9ogDe5rf46dASXh8r5DPIyH1Up3HhhROcFti'); // return array(...)
```
- To verify the hashed content.
```php
verify('Need to be hash', '$2y$10$cwzwDA.wXJitJMPQt9ogDe5rf46dASXh8r5DPIyH1Up3HhhROcFti'); // return boolean
```
## License
This package is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).