1--TEST-- 2openssl_private_encrypt() tests 3--EXTENSIONS-- 4openssl 5--FILE-- 6<?php 7$data = "Testing openssl_private_encrypt()"; 8$privkey = "file://" . __DIR__ . "/private_rsa_1024.key"; 9$pubkey = "file://" . __DIR__ . "/public.key"; 10$wrong = "wrong"; 11 12class test { 13 function __toString() { 14 return "test"; 15 } 16} 17$obj = new test; 18 19var_dump(openssl_private_encrypt($data, $encrypted, $privkey)); 20var_dump(openssl_private_encrypt($data, $encrypted, $pubkey)); 21var_dump(openssl_private_encrypt($data, $encrypted, $wrong)); 22var_dump(openssl_private_encrypt($data, $encrypted, $obj)); 23var_dump(openssl_private_encrypt($obj, $encrypted, $privkey)); 24openssl_public_decrypt($encrypted, $output, $pubkey); 25var_dump($output); 26?> 27--EXPECTF-- 28bool(true) 29 30Warning: openssl_private_encrypt(): key param is not a valid private key in %s on line %d 31bool(false) 32 33Warning: openssl_private_encrypt(): key param is not a valid private key in %s on line %d 34bool(false) 35 36Warning: openssl_private_encrypt(): key param is not a valid private key in %s on line %d 37bool(false) 38bool(true) 39string(4) "test" 40