Sample code for 30+ languages & platforms
PHP

Example: Crypt2.EncryptSb method

Demonstrates how to call the EncryptSb method.

Chilkat PHP Downloads

Chilkat2 PHP
<?php

use Chilkat2\BinData;
use Chilkat2\Crypt2;
use Chilkat2\StringBuilder;

$crypt = new Crypt2();

$bdEncrypted = new BinData();
$sbPlainText = new StringBuilder();

$sbPlainText->Append('Text to be encrypted');

// ...
// Set the secret key ...
// Set properties such as CryptAlgorithm, CipherMode, PaddingScheme, KeyLength
// Set the IV if needed ...
// ...

$crypt->Charset = 'utf-8';

try {
    $crypt->EncryptSb($sbPlainText, $bdEncrypted);
} catch (\Chilkat2\Exception $e) {
    echo $e->getMessage(), "\n";
    exit;
}