<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: PHP &amp; Java interoperable encryption</title>
	<atom:link href="http://www.spartanjava.com/2009/php-java-interoperable-encryption/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.spartanjava.com/2009/php-java-interoperable-encryption/</link>
	<description>Simple yet powerful Java programming</description>
	<lastBuildDate>Wed, 08 Feb 2012 15:58:05 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: suresh S</title>
		<link>http://www.spartanjava.com/2009/php-java-interoperable-encryption/comment-page-1/#comment-22382</link>
		<dc:creator>suresh S</dc:creator>
		<pubDate>Wed, 09 Nov 2011 11:29:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.spartanjava.com/?p=24#comment-22382</guid>
		<description>Nice Post..</description>
		<content:encoded><![CDATA[<p>Nice Post..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ricardoz</title>
		<link>http://www.spartanjava.com/2009/php-java-interoperable-encryption/comment-page-1/#comment-1835</link>
		<dc:creator>ricardoz</dc:creator>
		<pubDate>Mon, 14 Sep 2009 14:16:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.spartanjava.com/?p=24#comment-1835</guid>
		<description>Michael, how did you come up with the encrypted data? Are you sure you are using PKCS5 on the encrypting end?</description>
		<content:encoded><![CDATA[<p>Michael, how did you come up with the encrypted data? Are you sure you are using PKCS5 on the encrypting end?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael</title>
		<link>http://www.spartanjava.com/2009/php-java-interoperable-encryption/comment-page-1/#comment-1780</link>
		<dc:creator>Michael</dc:creator>
		<pubDate>Fri, 11 Sep 2009 15:44:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.spartanjava.com/?p=24#comment-1780</guid>
		<description>I am currently facing the same issue as above but I can not get the example to work. It may be for different reasons. Here is the complete code that I need to decrypt this text of as a beta test:

&lt;?php

function decrypt($key, $data) {
   $keyHex = bin2hex(base64_decode($key));
   $dataHex = bin2hex(base64_decode($data));
   $keyPacked = pack(&#039;H*&#039;,utf8_encode($keyHex));
   $input = pkcs5_pad(pack(&#039;H*&#039;, utf8_encode($dataHex)), 8);
 
 $bit_check=8; 
 $text_num =str_split($input,$bit_check);
 $text_num = $bit_check-strlen($text_num[count($text_num)-1]);
 for ($i=0;$i&lt;$text_num; $i++) {$input = $input . chr($text_num);}
 
 
   $td = mcrypt_module_open(MCRYPT_DES, &#039;&#039;, &#039;ecb&#039;, &#039;&#039;);
   $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
   mcrypt_generic_init($td, $keyPacked, $iv);
 
   $decrypted_data = mdecrypt_generic($td, $input);
   mcrypt_generic_deinit($td);
   mcrypt_module_close($td);
 
   return $decrypted_data;
}


function pkcs5_pad ($text, $blocksize)
{
    $pad = $blocksize - (strlen($text) % $blocksize);
    return $text . str_repeat(chr($pad), $pad);
}


$mkey = &quot;NynpHBZblyo=&quot;;
$mtoken = &quot;8iy4HCksTc1FbwV7WkYj7mDnHPEa6Frj&quot;;

$plaintextc = decrypt($mkey,$mtoken);
echo &quot;&quot;;
echo $plaintextc;

?&gt;

Here is the output:


8,&quot;�n�Gmѭ-�B��嬼�}R#v��M�iaG� 

Do you have any ideas? This is DES and not TRIPLEDES.</description>
		<content:encoded><![CDATA[<p>I am currently facing the same issue as above but I can not get the example to work. It may be for different reasons. Here is the complete code that I need to decrypt this text of as a beta test:</p>
<p>&lt;?php</p>
<p>function decrypt($key, $data) {<br />
   $keyHex = bin2hex(base64_decode($key));<br />
   $dataHex = bin2hex(base64_decode($data));<br />
   $keyPacked = pack(&#8216;H*&#8217;,utf8_encode($keyHex));<br />
   $input = pkcs5_pad(pack(&#8216;H*&#8217;, utf8_encode($dataHex)), 8);</p>
<p> $bit_check=8;<br />
 $text_num =str_split($input,$bit_check);<br />
 $text_num = $bit_check-strlen($text_num[count($text_num)-1]);<br />
 for ($i=0;$i&lt;$text_num; $i++) {$input = $input . chr($text_num);}</p>
<p>   $td = mcrypt_module_open(MCRYPT_DES, &#8221;, &#8216;ecb&#8217;, &#8221;);<br />
   $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size($td), MCRYPT_RAND);<br />
   mcrypt_generic_init($td, $keyPacked, $iv);</p>
<p>   $decrypted_data = mdecrypt_generic($td, $input);<br />
   mcrypt_generic_deinit($td);<br />
   mcrypt_module_close($td);</p>
<p>   return $decrypted_data;<br />
}</p>
<p>function pkcs5_pad ($text, $blocksize)<br />
{<br />
    $pad = $blocksize &#8211; (strlen($text) % $blocksize);<br />
    return $text . str_repeat(chr($pad), $pad);<br />
}</p>
<p>$mkey = &#8220;NynpHBZblyo=&#8221;;<br />
$mtoken = &#8220;8iy4HCksTc1FbwV7WkYj7mDnHPEa6Frj&#8221;;</p>
<p>$plaintextc = decrypt($mkey,$mtoken);<br />
echo &#8220;&#8221;;<br />
echo $plaintextc;</p>
<p>?&gt;</p>
<p>Here is the output:</p>
<p>8,&#8221;�n�Gmѭ-�B��嬼�}R#v��M�iaG� </p>
<p>Do you have any ideas? This is DES and not TRIPLEDES.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

