<?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>Hypn.za.net &#187; Ruby on Rails</title>
	<atom:link href="http://www.hypn.za.net/blog/category/programming/ruby-on-rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hypn.za.net/blog</link>
	<description>Games, programming, and general geekyness =)</description>
	<lastBuildDate>Fri, 27 Jan 2012 09:37:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>String to Hex / Hex to String &#8211; in Ruby :D</title>
		<link>http://www.hypn.za.net/blog/2010/11/28/string-to-hex-hex-to-string-in-ruby-d/</link>
		<comments>http://www.hypn.za.net/blog/2010/11/28/string-to-hex-hex-to-string-in-ruby-d/#comments</comments>
		<pubDate>Sun, 28 Nov 2010 11:07:33 +0000</pubDate>
		<dc:creator>Hypn</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.hypn.za.net/blog/?p=423</guid>
		<description><![CDATA[I&#8217;m busy converting a project of mine from PHP in to Ruby, and one of the things it needs to be able to do is convert a bunch of hex characters into a string (and vice versa)&#8230; which I wasn&#8217;t sure how to do, so I hit Google. As it turns out there seem to [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m busy converting a project of mine from PHP in to Ruby, and one of the things it needs to be able to do is convert a bunch of hex characters into a string (and vice versa)&#8230; which I wasn&#8217;t sure how to do, so I hit Google. As it turns out there seem to be several other people who&#8217;ve needed to do the same thing, without finding the answer they were looking for, so I got to trying to code my own functions and managed to come up with this:</p>
<blockquote><pre># hex_to_string("486578546f537472") returns "HexToStr"
def hex_to_string(str)
  returned = ''
  for i in (0..str.length).step(2)
    unless str[i].nil?
      hex_chr = str[i].chr + str[i+1].chr
      returned += hex_chr.hex.chr
    end
  end
  returned
end</pre>
</blockquote>
<blockquote><pre># string_to_hex("StrToHex") returns "537472546f486578"
def string_to_hex(str)
  returned = ''
  for i in (0..str.length)
    unless str[i].nil?
      returned += str[i].to_s(16)
    end
  end
  returned
end</pre>
</blockquote>
<p>I&#8217;m still new to Ruby, and don&#8217;t really know what I&#8217;m doing, so please feel free to make any improvements or suggestions. You can find the latest versions of these functions on github: <a href="https://github.com/hypn/HexToString">https://github.com/hypn/HexToString</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hypn.za.net/blog/2010/11/28/string-to-hex-hex-to-string-in-ruby-d/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby on Rails</title>
		<link>http://www.hypn.za.net/blog/2008/03/03/ruby-on-rails/</link>
		<comments>http://www.hypn.za.net/blog/2008/03/03/ruby-on-rails/#comments</comments>
		<pubDate>Mon, 03 Mar 2008 09:56:48 +0000</pubDate>
		<dc:creator>Hypn</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://hypn.za.net/blog/?p=5</guid>
		<description><![CDATA[I&#8217;m trying to learn Ruby&#8230; on Rails. sereNity is helping me :)]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m trying to learn <a href="http://www.ruby-lang.org/en/" title="Ruby" target="_blank">Ruby</a>&#8230; on <a href="http://www.rubyonrails.org/" title="Ruby on Rails" target="_blank">Rails</a>.</p>
<p>sereNity is helping me :)</p>
<p style="text-align: center"><img src="/images/ruby.jpg" alt="Ruby" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hypn.za.net/blog/2008/03/03/ruby-on-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

