[PHP] Typecasting question

2012-02-03 Thread jas

I am familiar with typecasting. Booleans, ints, strings, etc.

However while using an extension, more specifically the OpenSSL 
extension I have come across a problem I am not entirely familiar with.


I have an array that looks like...

array('config' = 'config/openssl.cnf',
  'encrypt_key'= true,
  'private_key_type'   = 'OPENSSL_KEYTYPE_RSA',
  'digest_algorithm'   = 'sha256',
  'private_key_bits'   = 512,
  'x509_extensions'= 'usr_cert',
  'encrypt_key_cipher' = 'OPENSSL_CIPHER_3DES');

And according to the current OpenSSL documentation regarding the 
configuration constants 
(http://www.php.net/manual/en/openssl.ciphers.php) the array needs to 
have the 'private_key_type' and 'encrypt_key_cipher' elements as an INT 
value vs the string they are currently. Like so.


array('private_key_type'   = OPENSSL_KEYTYPE_RSA,
  'encrypt_key_cipher' = OPENSSL_CIPHER_3DES);

I have tried to perform typecasting these two elements as an int but 
because they are specific to the extension I am not certain how I should 
go about doing this.


According to the source for php (the openssl.c) file is an internal 
attribute that I cannot find an integer value for to set it manually vs. 
using the pre-defined constant values mentioned in the docs.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Typecasting question

2012-02-03 Thread Marco Behnke
Am 03.02.12 17:11, schrieb jas:
 I am familiar with typecasting. Booleans, ints, strings, etc.

 However while using an extension, more specifically the OpenSSL
 extension I have come across a problem I am not entirely familiar with.

 I have an array that looks like...

 array('config' = 'config/openssl.cnf',
   'encrypt_key'= true,
   'private_key_type'   = 'OPENSSL_KEYTYPE_RSA',

remove the quotes around the constant, it must be

'private_key_type'   = OPENSSL_KEYTYPE_RSA,

   'digest_algorithm'   = 'sha256',
   'private_key_bits'   = 512,
   'x509_extensions'= 'usr_cert',
   'encrypt_key_cipher' = 'OPENSSL_CIPHER_3DES');

same here

-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz




signature.asc
Description: OpenPGP digital signature