Encrypt the string.

Twine\Str::encrypt( string $key, [ string $cipher = 'AES-128-CBC' ] ) : Twine\Str

Parameters

$key The key for encrypting
$cipher The cipher method

Supported cipher methods:

  • AES-128-CBC
  • AES-256-CBC

Examples

$string = new Twine\Str('john pinkerton');

        $string->encrypt('secret'); // Returns something like '$DZpEm9ZFec9ybxF7$y2rc62EapV8p+xOKGaQHKA==$pKe7S3T7tf8jaXWpUHc='