<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Steve&#039;s Blog &#187; obfuscated</title>
	<atom:link href="http://crindigo.com/blog/tag/obfuscated/feed/" rel="self" type="application/rss+xml" />
	<link>http://crindigo.com/blog</link>
	<description>Escapades of a web programmer</description>
	<lastBuildDate>Sun, 18 Sep 2011 04:40:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4-alpha-19719</generator>
		<item>
		<title>Obfuscated Cake</title>
		<link>http://crindigo.com/blog/2009/12/obfuscated-cake/</link>
		<comments>http://crindigo.com/blog/2009/12/obfuscated-cake/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 03:52:25 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[imaging]]></category>
		<category><![CDATA[obfuscated]]></category>

		<guid isPermaLink="false">http://crindigo.com/blog/?p=32</guid>
		<description><![CDATA[Almost forgot about this one. I wrote it back in June 2008 for Jeremy&#8217;s birthday since he was having a rough day. Like the heart, this is code in the shape of a birthday cake (well, as long as you &#8230; <a href="http://crindigo.com/blog/2009/12/obfuscated-cake/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Almost forgot about this one. I wrote it back in June 2008 for <a href="http://www.jeremyprivett.com/">Jeremy&#8217;s</a> birthday since he was having a rough day. Like the heart, this is code in the shape of a birthday cake (well, as long as you use some imagination <img src='http://crindigo.com/blog/wp-includes/images/smilies/icon_razz.gif' alt=':-P' class='wp-smiley' /> ) that draws a birthday cake. A chocolate one.</p>
<p>The code first draws the main cake rectangle. After that, it loops three times to draw the rectangles for the candlesticks, polygons for the flames, then orange circles with an alpha channel for the light. It finishes off with a series of lines whose lengths are determined by the sine function, used for the frosting.</p>
<p><a href="http://crindigo.com/birthday.php">Here&#8217;s the output.</a></p>
<pre class="brush: php; title: ; notranslate">
&lt;?php               header             ('Content'.
'-type:'.          'image/png'         );$f = 'im'.
'agecre'.          'atetrueco'.        'lor';$im=$f
(250,250);         $g='imagef'.        'illedrect'.
'angle';$g         ($im,10,120,        240,240,(630*
10000)+ 37         *100+44);for        ($i=0;$i&lt;3;$i
++){$x=60+         $i*60;$g($im        ,$x+2,50,$x+8,
120,0xeeeeee);$h=str_rot13('vzntrsvyyrqcbyltba');$h(
$im,array($x,50,$x+5,30,$x+10,50),3,0xc00000);$h($im,
array($x+2,50,$x+ 5,40,$x+8,50),3, 0xff8000);$h ($im,
array($x+3,50,$x+5,45,$x+7,50),3,0x0000ff);$el='ima'.
'gefilledellipse';$el($im,$x+5,40,40,40,0x48ffa000);}
$l='i'.'m'.'a'. 'g'.'e'.'l'.'in'.'e';$c=0xd0d0ff; for
($i=10;$i&lt;=240;$i++){$y=130+3* sin(($i-10)/2);$l($im,
$i,120,$i,$y,$c);}$p=strrev('egami').'png';$d='imag';
$d.='ede';$de='str';$d.=$de;$d.='oy';$p($im);$d($im);
</pre>
<p>Unobfuscated version:</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php

header('Content-type: image/png');
$img = imageCreateTrueColor(250, 250);
imageFilledRectangle($img, 10, 120, 240, 240, 0x603000);

// loop through the 3 candles
for ($i = 0; $i &lt; 3; $i++) {
	$x = 60 + $i * 60;
	// candlestick, red flame, orange flame, blue flame, light
	imageFilledRectangle($img, $x + 2, 50, $x + 8, 120, 0xEEEEEE);
	imageFilledPolygon($img, array($x, 50, $x + 5, 30, $x + 10, 50), 3, 0xC00000);
	imageFilledPolygon($img, array($x + 2, 50, $x + 5, 40, $x + 8, 50), 3, 0xFF8000);
	imageFilledPolygon($img, array($x + 3, 50, $x + 5, 45, $x + 7, 50), 3, 0x0000FF);
	imageFilledEllipse($img, $x + 5, 40, 40, 40, 0x48FFA000);
}

// frosting
for ($i = 10; $i &lt;= 240; $i++) {
	$y = 130 + 3 * sin(($i - 10) / 2);
	imageLine($img, $i, 120, $i, $y, 0xD0D0FF);
}

imagePNG($img);
imageDestroy($img);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://crindigo.com/blog/2009/12/obfuscated-cake/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Obfuscated Heart</title>
		<link>http://crindigo.com/blog/2009/12/obfuscated-heart/</link>
		<comments>http://crindigo.com/blog/2009/12/obfuscated-heart/#comments</comments>
		<pubDate>Mon, 07 Dec 2009 03:42:25 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[imaging]]></category>
		<category><![CDATA[obfuscated]]></category>

		<guid isPermaLink="false">http://crindigo.com/blog/?p=9</guid>
		<description><![CDATA[I originally wrote this in July 2006 for PHP image generation practice, but decided to repost it. Basically, it&#8217;s code written in the shape of a heart, that draws a heart. Going more in-depth, the code uses polar coordinates to &#8230; <a href="http://crindigo.com/blog/2009/12/obfuscated-heart/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I originally wrote this in July 2006 for PHP image generation practice, but decided to repost it. Basically, it&#8217;s code written in the shape of a heart, that draws a heart.</p>
<p>Going more in-depth, the code uses polar coordinates to draw a cardioid-like figure, which are converted into cartesian coordinates via the cfp_x() and cfp_y() functions. The new coordinates are then used in PHP&#8217;s <a href="http://php.net/imagefilledpolygon">imageFilledPolygon()</a> function to draw the shape.</p>
<p>The formula to create the heart is simply done by setting the radius equal to the angle, rotated 90 degrees so that the shape is right-side up. So, at 0, the coordinates are at the origin &#8211; the sharp valley of the heart. At 180, the coordinates are at the bottom point of the heart.</p>
<p>View the output <a href="http://crindigo.com/code/php/heart.php">here</a>.</p>
<pre class="brush: php; title: ; notranslate">
           function                cfp_x($ox,
     $a,$d) {return ($ox+    round((cos (deg2rad($a
   ))*$d)));}function cfp_y($oy, $a, $d){return ($oy+
  round((sin(deg2rad($a)) * $d)));} $crd=array();$ct=0;
 $im=imageCreateTrueColor(250,250);$c=imageColorAllocate
 ($im,255,0,0);header(&quot;Content-type: image/png&quot;);for($i
  =-180;$i&lt;180;$i++){$crd[]=cfp_x(125,$i -90,abs($i));
    $crd[] = cfp_y(50, $i - 90, abs($i) ); $ct++;}
        imageFilledPolygon($im, $crd,$ct,$c);
            imagePNG($im);imageDestroy
                      (($im));
                         ?&gt;
</pre>
<p>Unobfuscated version:</p>
<pre class="brush: php; title: ; notranslate">
function cfp_x($origin_x, $angle, $radius) {
    return $origin_x + round(cos(deg2rad($angle)) * $radius);
}
function cfp_y($origin_y, $angle, $radius) {
    return $origin_y + round(sin(deg2rad($angle)) * $radius);
}

$coords = array();
$num_pts = 0;
$img = imageCreateTrueColor(250, 250);

for ($i = -180; $i &lt; 180; $i++) {
    $coords[] = cfp_x(125, $i - 90, abs($i));
    $coords[] = cfp_y(50, $i - 90, abs($i));
    $num_pts++;
}

imageFilledPolygon($img, $coords, $num_pts, 0xFF0000);
header('Content-type: image/png');
imagePNG($img);
imageDestroy($img);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://crindigo.com/blog/2009/12/obfuscated-heart/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

