It's still experimental.
This extension allows Tink.
Documentation for Tink can be found at https://github.com/google/tink.
$ 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
php.ini:
extension=tink.so
- tink_encrypt — Tink encryption
- tink_decrypt — Tink decryption
implementation of https://github.com/google/tink/tree/master/examples/cc/helloworld command-line utility.
string tink_encrypt ( string $keyset_filename, string $data, string $associated_data )
Tink encryption.
-
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.
Returns the encryption data or FALSE if an error occurred.
string tink_decrypt ( string $keyset_filename, string $data, string $associated_data )
Tink decryption.
-
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.
Returns the decryption data or FALSE if an error occurred.
$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);