<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: cipher code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Thu, 28 Aug 2008 11:26:53 GMT</pubDate>
    <description>DZone Snippets: cipher code</description>
    <item>
      <title>Rail Fence Cipher</title>
      <link>http://snippets.dzone.com/posts/show/5535</link>
      <description>Implementation&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;		public static string RailFenceCipher(string input){&lt;br /&gt;			// b.t.w we only use two rails&lt;br /&gt;			string rail1 = "";&lt;br /&gt;			string rail2 = "";&lt;br /&gt;			char[] arry = input.ToCharArray();&lt;br /&gt;			bool top = true;&lt;br /&gt;			foreach(char ch in arry){&lt;br /&gt;				if(top == true)&lt;br /&gt;					rail1 += ch.ToString();&lt;br /&gt;				else&lt;br /&gt;					rail2 += ch.ToString();&lt;br /&gt;				top = !top;&lt;br /&gt;			}&lt;br /&gt;			return rail1 + rail2;&lt;br /&gt;		}&lt;br /&gt;		public static string DeRailFenceCipher(string input){&lt;br /&gt;			// b.t.w we only use two rails&lt;br /&gt;			string rail1 = input.Substring(0,input.Length / 2);&lt;br /&gt;			string rail2 = input.Substring(input.Length / 2);&lt;br /&gt;			int r1 = 0;&lt;br /&gt;			int r2 = 0;&lt;br /&gt;			string o = "";&lt;br /&gt;			bool top = true;&lt;br /&gt;			while(o.Length != input.Length){&lt;br /&gt;				if(top == true){&lt;br /&gt;					o += rail1.Substring(r1, 1);&lt;br /&gt;					r1 ++;&lt;br /&gt;				}&lt;br /&gt;				else{&lt;br /&gt;					o += rail2.Substring(r2, 1);&lt;br /&gt;					r2 ++;&lt;br /&gt;				}&lt;br /&gt;				top = !top;&lt;br /&gt;			}&lt;br /&gt;			return o;&lt;br /&gt;		}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sat, 24 May 2008 14:45:05 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5535</guid>
      <author>mcr-joe (Joe Simpson)</author>
    </item>
    <item>
      <title>Bash: checking if a variable is a number</title>
      <link>http://snippets.dzone.com/posts/show/3143</link>
      <description>Shellscript checking if a variable is a number&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/bin/bash&lt;br /&gt;read VARIABLE&lt;br /&gt;if [ $VARIABLE -eq $VARIABLE 2&gt; /dev/null ]; then&lt;br /&gt;echo $VARIABLE is a number&lt;br /&gt;else&lt;br /&gt;echo $VARIABLE is not a number&lt;br /&gt;fi&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 13 Dec 2006 18:54:32 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3143</guid>
      <author>Grzechu (Grzegorz Rumatowski)</author>
    </item>
  </channel>
</rss>
