PHP code example of tooooony / aes_rsa_tree_linked_node

1. Go to this page and download the library: Download tooooony/aes_rsa_tree_linked_node 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/ */

    

tooooony / aes_rsa_tree_linked_node example snippets




namespace Tony\Mixed\Lib;

/**
 * 二叉树结点类
 */
class TreeNode
{
    // 结点的值
    public $val = null;
    
    // 结点的左子树
    public $left = null;
    
    // 结点的右子树
    public $right = null;
    
    public function __construct($value, $left=null, $right=null) 
    {
        $this->val = $value;
        $this->left = $left;
        $this->right = $right;
    }
}

use Tony\Mixed\Lib\AES;

$key = bin2hex(random_bytes(8));
$iv = bin2hex(random_bytes(8));
$msg = 'this is your message';

$aes = new AES($key, $iv);
$encrypted = $aes->encrypt($msg);

$decrypted = $aes->decrypt($encrypted);

if ( $decrypted == $msg ) {
	echo "aes works";
} else {
	echo "aes sucks";
}