php-general Digest 19 Oct 2012 00:07:20 -0000 Issue 8013
Topics (messages 319510 through 319519):
Re: Send php Mail not working in MAMP (non pro version)
319510 by: Jim Lucas
PHP to decode AES
319511 by: Rick Dwyer
319512 by: Rick Dwyer
319513 by: Matijn Woudt
319516 by: Rick Dwyer
319517 by: Matijn Woudt
319518 by: Adam Richardson
319519 by: Rick Dwyer
PHP 5.4.8 and PHP 5.3.18 released!
319514 by: Johannes Schlüter
[Ticket #3959] [ANNOUNCE] PHP 5.4.8 and PHP 5.3.18 released!
319515 by: helpdesk
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net
To post to the list, e-mail:
php-gene...@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
On 10/17/2012 05:00 PM, Dave wrote:
Make sure, if you happen to have install postfix as well, that it has
replaced your sendmail.
Then, from the cli, as your apache/php user, try sending an email using
sendmail.
# sendmail -v y...@email.com
testing
.
Thanks a lot Jim for the help...
sorry this is getting a bit above me... if you mean use the terminal I
have a friend that can help me soon try to change user to apache/php
user (not sure how yet) and test this
...
Did it work?
More then likely your php/apache process does not know where sendmail is or
does not have permission to use it.
Check in your php.ini file and see what is set as the sendmail_path
Mine is set like this:
; For Unix only. You may supply arguments as well (default: "sendmail -t
-i").
;sendmail_path =
As a standard user on my linux box I get this
[jlucas@jim ~]$ which sendmail
/usr/bin/which: no sendmail in (...)
But as root, I get this
[root@jim ~]# which sendmail
/usr/sbin/sendmail
So, make sure your apache&php user can see and execute sendmail
--
Jim Lucas
Ji Jim,
in the mamp php.ini file I had set like the demo to:
[mail function]
; For Win32 only.
;SMTP = localhost - these commented out as described
;smtp_port = 25 - these commented out as described
; For Win32 only.
;sendmail_from = m...@example.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
sendmail_path =/usr/sbin/sendmail -t -i -f m...@site.com
From your terminal, you will need to verify that /usr/sbin/sendmail
exists and can be called by your apache/php user.
First off, make sure that sendmail is installed and functioning.
I am not using sendmail that I know of. I didn't install anything -
just the basic NON PRO MAMP
Also I did not install postfix.
and I am using the basic php function mail()
You could get around using the mail function completely and use
phpmailer or SwiftMail. They would allow you to talk directly to an
outside SMTP server. In most cases, unless your web server happens to
serve as your mail server, you would want to relay your message(s)
through your official mail server.
--
Jim Lucas
http://www.cmsws.com/
http://www.cmsws.com/examples/
--- End Message ---
--- Begin Message ---
Hello all.
Has anyone ever tried to decode a JAVA AES/CBC encrypted string with PHP before?
I found a tutorial online with the following code to use as starting point, but
it fails to return anything readable:
$code ='Hello World';
$key = 'my key';
function decrypt($code, $key) {
$key = hex2bin($key);
$code = hex2bin($code);
$td = mcrypt_module_open("rijndael-128", "", "cbc", "");
mcrypt_generic_init($td, $key, "fedcba9876543210");
$decrypted = mdecrypt_generic($td, $code);
mcrypt_generic_deinit($td);
mcrypt_module_close($td);
return utf8_encode(trim($decrypted));
}
function hex2bin($hexdata) {
$bindata = "";
for ($i = 0; $i < strlen($hexdata); $i += 2) {
$bindata .= chr(hexdec(substr($hexdata, $i, 2)));
}
return $bindata;
}
echo decrypt($code, $key);
The above returns output containing a series of unprintable characters.
I thought maybe it was due to $code not being in a hex format, but after
converting to hex and resubmitting, I still unprintable characters.
Any info is appreciated.
--Rick
--- End Message ---
--- Begin Message ---
To correct what I posted below, $code that I'm passing to my function is
encrypted… not plain text:
ch7WvaSrCiHLstNeNUp5SkPfPgw0Z8vrNPJT+9vU7jN/C
--Rick
On Oct 18, 2012, at 12:06 PM, Rick Dwyer <rpdw...@earthlink.net> wrote:
> Hello all.
>
> Has anyone ever tried to decode a JAVA AES/CBC encrypted string with PHP
> before?
>
> I found a tutorial online with the following code to use as starting point,
> but it fails to return anything readable:
>
> $code ='Hello World';
> $key = 'my key';
>
> function decrypt($code, $key) {
> $key = hex2bin($key);
> $code = hex2bin($code);
> $td = mcrypt_module_open("rijndael-128", "", "cbc", "");
> mcrypt_generic_init($td, $key, "fedcba9876543210");
> $decrypted = mdecrypt_generic($td, $code);
> mcrypt_generic_deinit($td);
> mcrypt_module_close($td);
> return utf8_encode(trim($decrypted));
> }
>
>
> function hex2bin($hexdata) {
> $bindata = "";
> for ($i = 0; $i < strlen($hexdata); $i += 2) {
> $bindata .= chr(hexdec(substr($hexdata, $i, 2)));
> }
> return $bindata;
> }
> echo decrypt($code, $key);
>
> The above returns output containing a series of unprintable characters.
>
> I thought maybe it was due to $code not being in a hex format, but after
> converting to hex and resubmitting, I still unprintable characters.
>
> Any info is appreciated.
>
>
>
>
> --Rick
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--- End Message ---
--- Begin Message ---
On Thu, Oct 18, 2012 at 7:19 PM, Rick Dwyer <rpdw...@earthlink.net> wrote:
> To correct what I posted below, $code that I'm passing to my function is
> encrypted… not plain text:
>
> ch7WvaSrCiHLstNeNUp5SkPfPgw0Z8vrNPJT+9vU7jN/C
>
> --Rick
>
>
> On Oct 18, 2012, at 12:06 PM, Rick Dwyer <rpdw...@earthlink.net> wrote:
>
>> Hello all.
>>
>> Has anyone ever tried to decode a JAVA AES/CBC encrypted string with PHP
>> before?
>>
>> I found a tutorial online with the following code to use as starting point,
>> but it fails to return anything readable:
>>
>> $code ='Hello World';
>> $key = 'my key';
>>
>> function decrypt($code, $key) {
>> $key = hex2bin($key);
>> $code = hex2bin($code);
>> $td = mcrypt_module_open("rijndael-128", "", "cbc", "");
>> mcrypt_generic_init($td, $key, "fedcba9876543210");
>> $decrypted = mdecrypt_generic($td, $code);
>> mcrypt_generic_deinit($td);
>> mcrypt_module_close($td);
>> return utf8_encode(trim($decrypted));
>> }
>>
>>
>> function hex2bin($hexdata) {
>> $bindata = "";
>> for ($i = 0; $i < strlen($hexdata); $i += 2) {
>> $bindata .= chr(hexdec(substr($hexdata, $i, 2)));
>> }
>> return $bindata;
>> }
>> echo decrypt($code, $key);
>>
>> The above returns output containing a series of unprintable characters.
>>
>> I thought maybe it was due to $code not being in a hex format, but after
>> converting to hex and resubmitting, I still unprintable characters.
>>
>> Any info is appreciated.
>>
>> --Rick
Your key is not in hexadecimal, could it be Base64?
--- End Message ---
--- Begin Message ---
On Oct 18, 2012, at 2:38 PM, Matijn Woudt <tijn...@gmail.com> wrote:
> On Thu, Oct 18, 2012 at 7:19 PM, Rick Dwyer <rpdw...@earthlink.net> wrote:
>> To correct what I posted below, $code that I'm passing to my function is
>> encrypted… not plain text:
>>
>> ch7WvaSrCiHLstNeNUp5SkPfPgw0Z8vrNPJT+9vU7jN/C
>>
>> --Rick
>>
>>
>> On Oct 18, 2012, at 12:06 PM, Rick Dwyer <rpdw...@earthlink.net> wrote:
>>
>>> Hello all.
>>>
>>> Has anyone ever tried to decode a JAVA AES/CBC encrypted string with PHP
>>> before?
>>>
>>> I found a tutorial online with the following code to use as starting point,
>>> but it fails to return anything readable:
>>>
>>> $code ='Hello World';
>>> $key = 'my key';
>>>
>>> function decrypt($code, $key) {
>>> $key = hex2bin($key);
>>> $code = hex2bin($code);
>>> $td = mcrypt_module_open("rijndael-128", "", "cbc", "");
>>> mcrypt_generic_init($td, $key, "fedcba9876543210");
>>> $decrypted = mdecrypt_generic($td, $code);
>>> mcrypt_generic_deinit($td);
>>> mcrypt_module_close($td);
>>> return utf8_encode(trim($decrypted));
>>> }
>>>
>>>
>>> function hex2bin($hexdata) {
>>> $bindata = "";
>>> for ($i = 0; $i < strlen($hexdata); $i += 2) {
>>> $bindata .= chr(hexdec(substr($hexdata, $i, 2)));
>>> }
>>> return $bindata;
>>> }
>>> echo decrypt($code, $key);
>>>
>>> The above returns output containing a series of unprintable characters.
>>>
>>> I thought maybe it was due to $code not being in a hex format, but after
>>> converting to hex and resubmitting, I still unprintable characters.
>>>
>>> Any info is appreciated.
>>>
>>> --Rick
>
>
> Your key is not in hexadecimal, could it be Base64?
I tried base64_decode($code) without luck as well.
--Rick
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--- End Message ---
--- Begin Message ---
Op 18 okt. 2012 21:50 schreef "Rick Dwyer" <rpdw...@earthlink.net> het
volgende:
>
> On Oct 18, 2012, at 2:38 PM, Matijn Woudt <tijn...@gmail.com> wrote:
>
> > On Thu, Oct 18, 2012 at 7:19 PM, Rick Dwyer <rpdw...@earthlink.net>
wrote:
> >> To correct what I posted below, $code that I'm passing to my function
is encrypted… not plain text:
> >>
> >> ch7WvaSrCiHLstNeNUp5SkPfPgw0Z8vrNPJT+9vU7jN/C
> >>
> >> --Rick
> >>
> >>
> >> On Oct 18, 2012, at 12:06 PM, Rick Dwyer <rpdw...@earthlink.net> wrote:
> >>
> >>> Hello all.
> >>>
> >>> Has anyone ever tried to decode a JAVA AES/CBC encrypted string with
PHP before?
> >>>
> >>> I found a tutorial online with the following code to use as starting
point, but it fails to return anything readable:
> >>>
> >>> $code ='Hello World';
> >>> $key = 'my key';
> >>>
> >>> function decrypt($code, $key) {
> >>> $key = hex2bin($key);
> >>> $code = hex2bin($code);
> >>> $td = mcrypt_module_open("rijndael-128", "", "cbc", "");
> >>> mcrypt_generic_init($td, $key, "fedcba9876543210");
> >>> $decrypted = mdecrypt_generic($td, $code);
> >>> mcrypt_generic_deinit($td);
> >>> mcrypt_module_close($td);
> >>> return utf8_encode(trim($decrypted));
> >>> }
> >>>
> >>>
> >>> function hex2bin($hexdata) {
> >>> $bindata = "";
> >>> for ($i = 0; $i < strlen($hexdata); $i += 2) {
> >>> $bindata .= chr(hexdec(substr($hexdata, $i, 2)));
> >>> }
> >>> return $bindata;
> >>> }
> >>> echo decrypt($code, $key);
> >>>
> >>> The above returns output containing a series of unprintable
characters.
> >>>
> >>> I thought maybe it was due to $code not being in a hex format, but
after converting to hex and resubmitting, I still unprintable characters.
> >>>
> >>> Any info is appreciated.
> >>>
> >>> --Rick
> >
> >
> > Your key is not in hexadecimal, could it be Base64?
>
> I tried base64_decode($code) without luck as well.
>
>
How about no conversion at all? Just use it as a plaintext key?
Don't you have the java source that explains in what format the key is?
--- End Message ---
--- Begin Message ---
On Thu, Oct 18, 2012 at 12:06 PM, Rick Dwyer <rpdw...@earthlink.net> wrote:
> Hello all.
>
> Has anyone ever tried to decode a JAVA AES/CBC encrypted string with PHP
> before?
>
> I found a tutorial online with the following code to use as starting point,
> but it fails to return anything readable:
>
> $code ='Hello World';
> $key = 'my key';
>
> function decrypt($code, $key) {
> $key = hex2bin($key);
> $code = hex2bin($code);
> $td = mcrypt_module_open("rijndael-128", "", "cbc", "");
> mcrypt_generic_init($td, $key, "fedcba9876543210");
> $decrypted = mdecrypt_generic($td, $code);
> mcrypt_generic_deinit($td);
> mcrypt_module_close($td);
> return utf8_encode(trim($decrypted));
> }
>
>
> function hex2bin($hexdata) {
> $bindata = "";
> for ($i = 0; $i < strlen($hexdata); $i += 2) {
> $bindata .= chr(hexdec(substr($hexdata, $i, 2)));
> }
> return $bindata;
> }
> echo decrypt($code, $key);
>
> The above returns output containing a series of unprintable characters.
>
> I thought maybe it was due to $code not being in a hex format, but after
> converting to hex and resubmitting, I still unprintable characters.
>
> Any info is appreciated.
Can you post the Java code you're using? There are things such as the
padding specification that could cause some issues.
Adam
--
Nephtali: A simple, flexible, fast, and security-focused PHP framework
http://nephtaliproject.com
--- End Message ---
--- Begin Message ---
On Oct 18, 2012, at 4:39 PM, Adam Richardson <simples...@gmail.com> wrote:
> On Thu, Oct 18, 2012 at 12:06 PM, Rick Dwyer <rpdw...@earthlink.net> wrote:
>> Hello all.
>>
>> Has anyone ever tried to decode a JAVA AES/CBC encrypted string with PHP
>> before?
>>
>> I found a tutorial online with the following code to use as starting point,
>> but it fails to return anything readable:
>>
>> $code ='Hello World';
>> $key = 'my key';
>>
>> function decrypt($code, $key) {
>> $key = hex2bin($key);
>> $code = hex2bin($code);
>> $td = mcrypt_module_open("rijndael-128", "", "cbc", "");
>> mcrypt_generic_init($td, $key, "fedcba9876543210");
>> $decrypted = mdecrypt_generic($td, $code);
>> mcrypt_generic_deinit($td);
>> mcrypt_module_close($td);
>> return utf8_encode(trim($decrypted));
>> }
>>
>>
>> function hex2bin($hexdata) {
>> $bindata = "";
>> for ($i = 0; $i < strlen($hexdata); $i += 2) {
>> $bindata .= chr(hexdec(substr($hexdata, $i, 2)));
>> }
>> return $bindata;
>> }
>> echo decrypt($code, $key);
>>
>> The above returns output containing a series of unprintable characters.
>>
>> I thought maybe it was due to $code not being in a hex format, but after
>> converting to hex and resubmitting, I still unprintable characters.
>>
>> Any info is appreciated.
>
> Can you post the Java code you're using? There are things such as the
> padding specification that could cause some issues.
>
> Adam
>
Hi all. We were able to get it to work. But thank you for your replies.
But for anyone interested (including anyone who has emailed me privately
implying I was up to something untoward), the specs from the client were as
follows:
Unencrypted: "2012-10-18T10:57:43+0200 someurl.com"
Encrypted + base64: "ch7WvaSrCiHLstNeNUp5SkPfPGqZ8vrNPJT+9vU7jN/C"
Encrypt algorithm: AES/CBC, PKCS5Padding, IV of 16 NULL (0x0 hex) bytes
Key: "someKEY123-12346"
--------------------------------------------------------------------------------------------------------------------
$iv = mcrypt_create_iv(32);
$key = 'someKEY123-12346';
$text = '2012-10-18T10:57:43+0200 someurl.com';
$size = mcrypt_get_block_size('rijndael-128', 'cbc');
$text = pkcs5_pad($text, $size);
$crypttext = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $text, MCRYPT_MODE_CBC,
$iv);
$decrypttext = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key,
base64_decode('ch7WvaSrCiHLstNeNUp5SkPfPGqZ8vrNPJT+9vU7jN/C'), MCRYPT_MODE_CBC,
$iv);
function pkcs5_pad ($text, $blocksize)
{
$pad = $blocksize - (strlen($text) % $blocksize);
return $text . str_repeat(chr($pad), $pad);
}
echo $decrypttext;
…
--- End Message ---
--- Begin Message ---
The PHP development team announces the immediate availability of PHP
5.4.8 and PHP 5.3.18. These releases fix about 20 bugs. All users of PHP
are encouraged to upgrade to PHP 5.4.8, or at least 5.3.18.
Key enhancements in these releases include:
* Fixed bug #63111 (is_callable() lies for abstract static method)
* Fixed bug #61442 (exception threw in __autoload can not be catched)
The full list of changes are recorded in the ChangeLog on
http://www.php.net/ChangeLog-5.php
For source downloads of PHP 5.4.8 and PHP 5.3.18 please visit our
downloads page at http://www.php.net/downloads.php
Windows binaries can be found on http://windows.php.net/download/
David Soria Parra, Stanislav Malyshev and Johannes Schlüter
PHP Release Team
--- End Message ---
--- Begin Message ---
On Oct 18, 2012 @ 07:54 pm, johan...@php.net wrote:
The PHP development team announces the immediate availability of PHP
5.4.8 and PHP 5.3.18. These releases fix about 20 bugs. All users of PHP
are encouraged to upgrade to PHP 5.4.8, or at least 5.3.18.
Key enhancements in these releases include:
* Fixed bug #63111 (is_callable() lies for abstract static method)
* Fixed bug #61442 (exception threw in __autoload can not be catched)
The full list of changes are recorded in the ChangeLog on
http://www.php.net/ChangeLog-5.php
For source downloads of PHP 5.4.8 and PHP 5.3.18 please visit our
downloads page at http://www.php.net/downloads.php
Windows binaries can be found on http://windows.php.net/download/
David Soria Parra, Stanislav Malyshev and Johannes Schlüter
PHP Release Team
--
PHP Announcements Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
________________________________
This is an automated response. Your issue has been noted. We'll be in touch
soon.
Please reply to this email or visit the URL below with any additional details.
http://82.152.125.117:9675/portal/view-help-request/3959
--- End Message ---