https://github.com/kjdev/php-ext-tink
Tink for PHP
https://github.com/kjdev/php-ext-tink
Last synced: 10 months ago
JSON representation
Tink for PHP
- Host: GitHub
- URL: https://github.com/kjdev/php-ext-tink
- Owner: kjdev
- Created: 2021-08-13T03:23:16.000Z (over 4 years ago)
- Default Branch: develop
- Last Pushed: 2021-08-13T03:27:04.000Z (over 4 years ago)
- Last Synced: 2025-02-09T06:44:16.080Z (about 1 year ago)
- Language: C++
- Size: 4.88 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Tink for PHP
**It's still experimental.**
This extension allows Tink.
Documentation for Tink can be found at [https://github.com/google/tink](https://github.com/google/tink).
## Build from sources
``` sh
$ git clone --depth=1 https://github.com/kjdev/php-ext-tink.git
$ phpize
$ ./configure --with-tink=[Tink C++ include/lib path]
$ make
$ make install
```
> Will need Tink's C ++ header files and libraries
## Configration
php.ini:
```
extension=tink.so
```
## Function
* tink\_encrypt — Tink encryption
* tink\_decrypt — Tink decryption
> implementation of https://github.com/google/tink/tree/master/examples/cc/helloworld
> command-line utility.
### tink\_encrypt — Tink encryption
#### Description
string **tink\_encrypt** ( string _$keyset_filename_, string _$data_, string _$associated_data_ )
Tink encryption.
#### Pameters
* _keyset_filename_
name of the file with the keyset to be used for encryption.
* _data_
a string to encryption.
* _associated_data_
a string to be used as assciated data.
#### Return Values
Returns the encryption data or FALSE if an error occurred.
### tink\_decrypt — Tink decryption
#### Description
string **tink\_decrypt** ( string _$keyset_filename_, string _$data_, string _$associated_data_ )
Tink decryption.
#### Pameters
* _keyset_filename_
name of the file with the keyset to be used for encryption.
* _data_
a string to decryption.
* _associated_data_
a string to be used as assciated data.
#### Return Values
Returns the decryption data or FALSE if an error occurred.
## Examples
```php
$keyset_file = 'keyset.json'; // See: tests/keyset.json
$data = 'message';
$associated_data = 'associated-data';
// encryption
$encrypt = tink_encrypt($keyset_file, $data, $associated_data);
// decryption
$var = tink_decrypt($keyset_file, $encrypt, $associated_data);
var_dump($var);
```