PHP code example of tankfairies / tcrypt

1. Go to this page and download the library: Download tankfairies/tcrypt library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tankfairies / tcrypt example snippets


$keys = new Keys();
$keys->setPasswordAndSalt('senders_password', 'a_custom_salt_at_least_15_chars_long');
$thePublicSenderKey = $keys->getPublicKey();

$keys = new Keys();
$keys->setPasswordAndSalt('receivers_password', 'a_custom_salt_at_least_15_chars_long');
$thePublicReceiverKey = $keys->getPublicKey();

$crypt = new Encrypt();
$crypt
    ->setLocalKeys($sendKeys)
    ->setForeignKey($thePublicReceiverKey);

$encryptedMessage = $crypt->enc('my secret message');

$decrypt = new Decrypt();
$decrypt
    ->setLocalKeys($keys)
    ->setForeignKey($thePublicSenderKey);

$decryptedMessage = $decrypt->dec($encryptedMessage);