https://github.com/arzzen/php-time-lock-encryption
Time Lock Encryption Class
https://github.com/arzzen/php-time-lock-encryption
decryption encrypted-data encryption fernet iteration lock-encryption period php
Last synced: about 2 months ago
JSON representation
Time Lock Encryption Class
- Host: GitHub
- URL: https://github.com/arzzen/php-time-lock-encryption
- Owner: arzzen
- License: mit
- Created: 2015-05-26T20:38:36.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2020-02-05T09:23:27.000Z (over 5 years ago)
- Last Synced: 2025-03-21T13:12:49.463Z (3 months ago)
- Topics: decryption, encrypted-data, encryption, fernet, iteration, lock-encryption, period, php
- Language: PHP
- Size: 20.5 KB
- Stars: 8
- Watchers: 4
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Time Lock Encryption Class [](https://travis-ci.org/arzzen/php-time-lock-encryption) [](https://packagist.org/packages/arzzen/php-time-lock-encryption) [](https://packagist.org/packages/arzzen/php-time-lock-encryption)
Implementation of timed-release crypto.
This class can encrypt data using key generated for a time period.
It takes an expression that defines a given time period and generates a key by creating iteratively hashes of the initial key in a cycle until the specified time as passed.
The class returns the encrypted data using the Fernet class with the generated key.
It can also decrypt previously encrypted data by regenerating the encryption key the same number of iterations that it were used to generate the key when the data was encrypted.
### Requirements
* PHP 5.3.3 or later
* hash extension
* openssl or mcrypt extension## Installation
You can install this library by using [Composer]. You can also view more info
about this on [Packagist].Add this to the `require` section in your `composer.json` file.
```json
{
"require": {
"arzzen/php-time-lock-encryption": "1.1.*"
}
}
```### Usage
```php
encrypt('+10 second', $message);
$iterations = $timeLock->getIterations();$decrypted = $timeLock->decrypt($encrypted, $iterations);
var_dump($message == $decrypted);
?>
```