xref: /PHP-8.3/ext/openssl/tests/bug72362.phpt (revision d23a8b33)
1--TEST--
2Bug #72362: OpenSSL Blowfish encryption is incorrect for short keys
3--EXTENSIONS--
4openssl
5--SKIPIF--
6<?php
7if (!in_array('bf-ecb', openssl_get_cipher_methods())) die('skip bf-ecb not available');
8?>
9--FILE--
10<?php
11var_dump(
12    bin2hex(
13        openssl_encrypt(
14            "this is a test string",
15            "bf-ecb",
16            "12345678",
17            OPENSSL_RAW_DATA | OPENSSL_DONT_ZERO_PAD_KEY
18        )
19    )
20);
21var_dump(
22    bin2hex(
23        openssl_encrypt(
24            "this is a test string",
25            "bf-ecb",
26            "1234567812345678",
27            OPENSSL_RAW_DATA
28        )
29    )
30);
31?>
32--EXPECT--
33string(48) "e3214d1b16e574828c8a3e222202dde81afd1ad2cb165ab3"
34string(48) "e3214d1b16e574828c8a3e222202dde81afd1ad2cb165ab3"
35