{"action":"created","issue":{"url":"https://api.github.com/repos/phpseclib/phpseclib/issues/1038","repository_url":"https://api.github.com/repos/phpseclib/phpseclib","labels_url":"https://api.github.com/repos/phpseclib/phpseclib/issues/1038/labels{/name}","comments_url":"https://api.github.com/repos/phpseclib/phpseclib/issues/1038/comments","events_url":"https://api.github.com/repos/phpseclib/phpseclib/issues/1038/events","html_url":"https://github.com/phpseclib/phpseclib/issues/1038","id":178546710,"number":1038,"title":"Wrong Blowfish Symmetric Key Encryption with PHP 5.2.9 (on 32-bit Linux OS)","user":{"login":"romucifu","id":22170463,"avatar_url":"https://avatars.githubusercontent.com/u/22170463?v=3","gravatar_id":"","url":"https://api.github.com/users/romucifu","html_url":"https://github.com/romucifu","followers_url":"https://api.github.com/users/romucifu/followers","following_url":"https://api.github.com/users/romucifu/following{/other_user}","gists_url":"https://api.github.com/users/romucifu/gists{/gist_id}","starred_url":"https://api.github.com/users/romucifu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/romucifu/subscriptions","organizations_url":"https://api.github.com/users/romucifu/orgs","repos_url":"https://api.github.com/users/romucifu/repos","events_url":"https://api.github.com/users/romucifu/events{/privacy}","received_events_url":"https://api.github.com/users/romucifu/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2016-09-22T08:07:02Z","updated_at":"2016-09-28T13:59:34Z","closed_at":null,"body":"I'm trying to encrypt a string using symmetric key encryption (blowfish) with PHP 5.2.9 and using phpseclib 1.0.3 (running in internal mode), the sample code I'm using it's pretty simple:\r\n\r\n```\r\ninclude('Crypt/Blowfish.php');\r\n\r\n$cipher = new Crypt_Blowfish();\r\n$data = 'abcdefghijk';\r\n\r\n$cipher->setKey('abcdef0123456789abcdefghi9876543');\r\n\r\necho bin2hex($cipher->encrypt($data));\r\n```\r\n\r\nthe generated output is (PHP 5.2.9):\r\n\r\n`0e1651fc54dd530757fc1711b696dac5`\r\n\r\nBut I've tried the same code with other servers (PHP 7.07, PHP 5.3.3, PHP 5.0.4) and ALL of them generate this:\r\n\r\n`ad7145c675b1c914bbfe379dc7293bf3`\r\n\r\nI suppose that the PHP 5.2.9 output is wrong. What could be the cause of this? Any clues?\r\n\r\nI also [submitted this question](http://stackoverflow.com/questions/39633723/wrong-blowfish-symmetric-key-encryption-with-php-5-2-9) to \"stackoverflow.com\".\r\n\r\nNOTE: I've attached the \"phpinfo\" data of the 5.2.9 PHP server (It's a Linux machine, probably CentOS distro)\r\n[phpinfo_529.txt](https://github.com/phpseclib/phpseclib/files/486732/phpinfo_529.txt)\r\n"},"comment":{"url":"https://api.github.com/repos/phpseclib/phpseclib/issues/comments/250174499","html_url":"https://github.com/phpseclib/phpseclib/issues/1038#issuecomment-250174499","issue_url":"https://api.github.com/repos/phpseclib/phpseclib/issues/1038","id":250174499,"user":{"login":"terrafrost","id":214474,"avatar_url":"https://avatars.githubusercontent.com/u/214474?v=3","gravatar_id":"","url":"https://api.github.com/users/terrafrost","html_url":"https://github.com/terrafrost","followers_url":"https://api.github.com/users/terrafrost/followers","following_url":"https://api.github.com/users/terrafrost/following{/other_user}","gists_url":"https://api.github.com/users/terrafrost/gists{/gist_id}","starred_url":"https://api.github.com/users/terrafrost/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/terrafrost/subscriptions","organizations_url":"https://api.github.com/users/terrafrost/orgs","repos_url":"https://api.github.com/users/terrafrost/repos","events_url":"https://api.github.com/users/terrafrost/events{/privacy}","received_events_url":"https://api.github.com/users/terrafrost/received_events","type":"User","site_admin":false},"created_at":"2016-09-28T13:59:34Z","updated_at":"2016-09-28T13:59:34Z","body":"Testing arbitrary versions of PHP is a little easier with Windows. You just go to http://museum.php.net/, download the binaries for the version you want, and bam, you're good to go.\r\n\r\nTesting arbitrary versions of PHP on Linux isn't so easy. With Linux I normally use Ubuntu. The easiest way to install a non-specific version of PHP is to do `sudo apt-get install php5` but that if you want to install a specific version then you pretty much have to compile it. And if you're going to do that you'll need to install the dependencies too. But for sufficiently old versions it may even take time and effort to track down the dependencies and even then you may need to find the right versions of the dependencies. Or else modify the dependencies to be BC with the version that PHP is expecting.\r\n\r\nLike a few years ago I tried to compile PHP 5.2.17 and here's what I had to do:\r\n\r\n```\r\nsudo apt-get update\r\nsudo apt-get install build-essential\r\nsudo apt-get install libxml2-dev\r\nsudo apt-get install libgmp3-dev\r\nwget http://museum.php.net/php5/php-5.2.17.tar.gz\r\ntar xvzf php-5.2.17.tar.gz\r\ncd php-5.2.17\r\nwget https://mail.gnome.org/archives/xml/2012-August/txtbgxGXAvz4N.txt\r\npatch -p0 < txtbgxGXAvz4N.txt\r\nsed -i 's/__GMP_BITS_PER_MP_LIMB/GMP_LIMB_BITS/g' ext/gmp/gmp.c\r\n./configure --prefix=/usr/local --enable-bcmath --enable-mcrypt --with-gmp\r\nmake\r\nsudo make install\r\n```\r\n\r\nIn your case GMP wouldn't be needed. It might be easier but it also might not be. None-the-less I can try to give it a shot as time permits but do realize that with each successive hoop I have to jump through the odds of me successfully reproducing the problem diminish."}}
{"actor":{"display_login":"terrafrost"}}