https://github.com/byjg/php-crypto
A generic repository for implement cryptographic algorithms with a customizable strong key generator.
https://github.com/byjg/php-crypto
Last synced: 6 months ago
JSON representation
A generic repository for implement cryptographic algorithms with a customizable strong key generator.
- Host: GitHub
- URL: https://github.com/byjg/php-crypto
- Owner: byjg
- License: mit
- Created: 2016-04-25T15:11:46.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-10-29T22:19:56.000Z (11 months ago)
- Last Synced: 2024-10-30T03:38:14.140Z (11 months ago)
- Language: PHP
- Size: 41 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Crypto
[](https://github.com/byjg/php-crypto/actions/workflows/phpunit.yml)
[](http://opensource.byjg.com)
[](https://github.com/byjg/php-crypto/)
[](https://opensource.byjg.com/opensource/licensing.html)
[](https://github.com/byjg/php-crypto/releases/)A "passwordless" cryptography library for symmetric encryption.
## How it works?
The algorithm is well-know, but the major problem is HOW to store the symmetric key. Instead of store the key,
this library use a key seed, and it is able to generate the key dynamically for each encrypting based
on a key seed. The key seed is a list of 32 lines of 32 bytes each.## Usage
```php
encrypt($text);
echo $object->decrypt($encrypted);
```- The algorithm needs to be one of the algorithms returned by `openssl_get_cipher_methods()`.
- The second parameter is the key seed. It is a list of 2-255 entries of 32 bytes each. You can generate it using the command
`BaseCrypto::getKeySet()`## Example
Below a full example:
```php
encrypt('My secret text needs to be encrypted');
echo $object->decrypt($enc) . "\n";
```**Important**
- Do not share the key seed.
- You'll only be able to decrypt the text if you have the same key seed used to encrypt it.## Additional Documentation
- [Advanced uses of KeySet class](docs/advanced-uses-keyset.md)
- [Interoperability with JavaScript](docs/interoperability.md)## Installation
```
composer require "byjg/crypto"
```## Running the tests
```
./vendor/bin/phpunit
```## Dependencies
```mermaid
flowchart TD
byjg/crypto --> ext-openssl
```----
[Open source ByJG](http://opensource.byjg.com)