Ejemplo n.º 1
0
        }
        $data00 = $key . $salt;
        $md5_hash = array();
        $md5_hash[0] = md5($data00, true);
        $result = $md5_hash[0];
        for ($i = 1; $i < $rounds; $i++) {
            $md5_hash[$i] = md5($md5_hash[$i - 1] . $data00, true);
            $result .= $md5_hash[$i];
        }
        $key = substr($result, 0, $key_length);
        $iv = substr($result, $key_length, $block_length);
        return openssl_decrypt($encrypted, "aes-" . $this->_nKeySize . "-cbc", $key, true, $iv);
    }
    /**
     * Sets the key-size for encryption/decryption in number of bits
     * @param  $nNewSize int The new key size. The valid integer values are: 128, 192, 256 (default) */
    function setMode($nNewSize)
    {
        if (is_null($nNewSize) || empty($nNewSize) || !is_int($nNewSize) || !in_array($nNewSize, self::$valid_key_sizes)) {
            return;
        }
        $this->_nKeySize = $nNewSize;
    }
}
$q = $_POST["str"];
$q = str_replace(' ', '+', $q);
echo "From Server Received: " . "<br>" . $q;
$encryptor = new \GibberishAES();
$encryptionKey = "abc";
$stringOriginal = $encryptor->decrypt($q, $encryptionKey);
echo "<br> From Server Sent: <br>" . $stringOriginal;