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