1--TEST-- 2Crypto\Cipher::encryptFinish basic usage. 3--FILE-- 4<?php 5$key = str_repeat('x', 32); 6$iv = str_repeat('i', 16); 7 8$data = str_repeat('a', 16); 9 10$cipher = new Crypto\Cipher('aes-256-cbc'); 11// invalid order 12try { 13 $cipher->encryptFinish(); 14} 15catch (Crypto\CipherException $e) { 16 if ($e->getCode() === Crypto\CipherException::FINISH_ENCRYPT_FORBIDDEN) { 17 echo "FINAL STATUS\n"; 18 } 19} 20// init first 21$cipher->encryptInit($key, $iv); 22echo bin2hex($cipher->encryptUpdate($data)) . "\n"; 23echo bin2hex($cipher->encryptFinish()) . "\n"; 24 25?> 26--EXPECT-- 27FINAL STATUS 288f8853a1685607133cb9ee0fc7a5b8a5 297103935cbc39ea680def0db0767e954e 30