https://github.com/wilon/authcode
PHP string Encryption and Decryption. From discuz source code.
https://github.com/wilon/authcode
php-encryption php-library
Last synced: 11 months ago
JSON representation
PHP string Encryption and Decryption. From discuz source code.
- Host: GitHub
- URL: https://github.com/wilon/authcode
- Owner: wilon
- Created: 2017-02-09T03:05:19.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-08-16T03:02:29.000Z (over 8 years ago)
- Last Synced: 2025-01-26T07:08:04.130Z (about 1 year ago)
- Topics: php-encryption, php-library
- Language: PHP
- Homepage:
- Size: 5.86 KB
- Stars: 1
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# wilon/authcode
[![Packagist][badge_package]][link-packagist]
[![Packagist Release][badge_release]][link-packagist]
[![Packagist Downloads][badge_downloads]][link-packagist]
[badge_package]: https://img.shields.io/badge/package-wilon/authcode-blue.svg?style=flat-square
[badge_release]: https://img.shields.io/packagist/v/wilon/authcode.svg?style=flat-square
[badge_downloads]: https://img.shields.io/packagist/dt/wilon/authcode.svg?style=flat-square
[link-packagist]: https://packagist.org/packages/wilon/authcode
PHP string Encryption and Decryption. From discuz source code.
## Installation & loading
Just add this line to your `composer.json` file:
```json
"wilon/authcode": "^1.1.3"
```
or
```sh
composer require wilon/authcode
```
## A Simple Example
##### Encode & Decode
```php
';
echo $result = Authcode::decode($auth, $key), '
';
```
```php
';
echo $result = Encryption\Authcode::decode($auth, $key), '
';
```
##### Only correct key can decode
```php
';
echo $result2 = Encryption\Authcode::decode($auth, 'otherKey'), '
'; # Can't get 'String'
```
##### Use expiry
```php
$key = 'IoUwe#(#FFFsfoaHFfa';
echo $auth = Encryption\Authcode::encode('String', $key, 10), '
';
sleep(11);
echo $result = Encryption\Authcode::decode($auth, $key), '
'; # Can't get 'String'
```
##### Encode remain equal signs
*python without '=' base64.b64decode() can't decode*
```php
'; # has '='
echo $result = Encryption\Authcode::decode($auth, $key), '
';
```