ID: 48498 Comment by: paul at mantisforge dot org Reported By: will at flourishlib dot com Status: Open Bug Type: COM related Operating System: Windows XP SP3 PHP Version: 5.2.10RC1 New Comment:
This functionality seems to work fine in the 5.3.0 rc builds ( PHP 5.3.0RC5-dev (cli) (built: Jun 27 2009 00:33:01) (DEBUG)). The following script appears to work for me against most of the capicom.utilities functions: <?php try { $util = new COM('CAPICOM.Utilities.1'); } catch (Exception $e) { echo $e->getMessage() . "\n"; echo 'exception initialising com object... terminating...'; } $string = 'foo'; $encoded = $util->Base64Encode($string); /* encoded string is \r\n terminated */ echo $encoded . ' is base 64 encoded string:' . $util- >Base64Decode($encoded) . "\n"; echo "\n\n"; $hex = $util->BinaryToHex($string); echo "BinaryToHex: " . $util->BinaryToHex($string) . "\n"; echo "hextobinary: " . $util->HexToBinary($hex) . "\n"; define( 'CAPICOM_ENCODE_BASE64', 0 ); echo "Random Number: " . $util->GetRandom(10, CAPICOM_ENCODE_BASE64) . "\n"; $variant = $util->BinaryStringToByteArray($string); $i = 0; foreach( $variant as $v) { echo "Byte(" . $i++ . "): " . $v . "\n"; } Outputing: ZgBvAG8A is base 64 encoded string:foo BinaryToHex: 66006F006F00 hextobinary: foo Random Number: PiMSnPtckiHFCQ== Byte(0): 102 Byte(1): 0 Byte(2): 111 Byte(3): 0 Byte(4): 111 Byte(5): 0 ---------------------------------- 1) It might be worth trying a newer version of php 2) it might be worth checking that the com object is registered correctly by attempting to access it from a vbscript Previous Comments: ------------------------------------------------------------------------ [2009-06-08 18:05:57] will at flourishlib dot com Description: ------------ In previous versions of PHP it was possible to create a COM object for CAPICOM to generate random data. I'm not sure at what version it broke, but now trying to instantiate the COM object, an exception is thrown with the message "Failed to create COM object 'CAPICOM.Utilities.1': Invalid syntax". This behavior seem to be present on both 5.2.9-2 and 5.2.10RC1. I've been unable to figure out what this error really means. The ProgID I'm specifying is valid according to Microsoft - http://msdn.microsoft.com/en-us/library/aa388176(VS.85).aspx. Any sort of direction would be useful in trying to solve this issue. Reproduce code: --------------- new COM('CAPICOM.Utilities.1'); Expected result: ---------------- A COM object that can be used. Actual result: -------------- An exception with the message: Failed to create COM object 'CAPICOM.Utilities.1': Invalid syntax ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=48498&edit=1