Annotation of embedaddon/php/ext/openssl/tests/011.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: openssl_encrypt() and openssl_decrypt() tests
        !             3: --SKIPIF--
        !             4: <?php if (!extension_loaded("openssl")) print "skip"; ?>
        !             5: --FILE--
        !             6: <?php
        !             7: $data = "openssl_encrypt() and openssl_decrypt() tests";
        !             8: $method = "AES-128-CBC";
        !             9: $password = "openssl";
        !            10: 
        !            11: $ivlen = openssl_cipher_iv_length($method);
        !            12: $iv    = '';
        !            13: srand(time() + ((microtime(true) * 1000000) % 1000000));
        !            14: while(strlen($iv) < $ivlen) $iv .= chr(rand(0,255));
        !            15: 
        !            16: $encrypted = openssl_encrypt($data, $method, $password, false, $iv);
        !            17: $output = openssl_decrypt($encrypted, $method, $password, false, $iv);
        !            18: var_dump($output);
        !            19: $encrypted = openssl_encrypt($data, $method, $password, true, $iv);
        !            20: $output = openssl_decrypt($encrypted, $method, $password, true, $iv);
        !            21: var_dump($output);
        !            22: ?>
        !            23: --EXPECT--
        !            24: string(45) "openssl_encrypt() and openssl_decrypt() tests"
        !            25: string(45) "openssl_encrypt() and openssl_decrypt() tests"
        !            26: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>