1--TEST--
2Crypto\Cipher::encryptInit basic usage.
3--FILE--
4<?php
5$cipher = new Crypto\Cipher('aes-256-cbc');
6$key = str_repeat('x', 32);
7$iv = str_repeat('i', 16);
8
9// key length
10try {
11	$cipher->encryptInit('short_key', $iv);
12}
13catch (Crypto\CipherException $e) {
14	if ($e->getCode() === Crypto\CipherException::KEY_LENGTH_INVALID) {
15		echo "SHORT KEY\n";
16	}
17}
18
19// iv length
20try {
21	$cipher->encryptInit($key, 'short_iv');
22}
23catch (Crypto\CipherException $e) {
24	if ($e->getCode() === Crypto\CipherException::IV_LENGTH_INVALID) {
25		echo "SHORT IV\n";
26	}
27}
28
29// iv empty when required
30try {
31	$cipher->encryptInit($key);
32}
33catch (Crypto\CipherException $e) {
34	if ($e->getCode() === Crypto\CipherException::IV_LENGTH_INVALID) {
35		echo "NO IV\n";
36	}
37}
38
39// both
40try {
41	$cipher->encryptInit('short_key');
42}
43catch (Crypto\CipherException $e) {
44	// key checking is first
45	if ($e->getCode() === Crypto\CipherException::KEY_LENGTH_INVALID) {
46		echo "BOTH\n";
47	}
48}
49
50$cipher->encryptInit($key, $iv);
51echo "SUCCESS\n";
52?>
53--EXPECT--
54SHORT KEY
55SHORT IV
56NO IV
57BOTH
58SUCCESS
59