<?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>Utter Randomness &#187; Programming</title>
	<atom:link href="http://matt-shaffer.com/blog/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://matt-shaffer.com/blog</link>
	<description></description>
	<lastBuildDate>Wed, 10 Feb 2010 01:57:43 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Signing Java Jar files</title>
		<link>http://matt-shaffer.com/blog/2009/01/10/signing-java-jar-files/</link>
		<comments>http://matt-shaffer.com/blog/2009/01/10/signing-java-jar-files/#comments</comments>
		<pubDate>Sat, 10 Jan 2009 17:27:26 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://matt-shaffer.com/?p=69</guid>
		<description><![CDATA[<br/>Well there&#8217;s never really been a  great place on the web for me to find out how, and after a lot of searching and trial and error, I found a way that works. If you have the JDK correctly installed and working in the classpath, go to Start-&#62;Run-&#62;cmd and hit enter, or vista users Start-&#62;type [...]]]></description>
			<content:encoded><![CDATA[<br/><p>Well there&#8217;s never really been a  great place on the web for me to find out how, and after a lot of searching and trial and error, I found a way that works. If you have the JDK correctly installed and working in the classpath, go to Start-&gt;Run-&gt;cmd and hit enter, or vista users Start-&gt;type in cmd in the searchbox-&gt;enter / click the only thing that shows up. Now type in &#8220;cd C:/path/to/your/directory&#8221; to get to the current directory of your jar file.</p>
<pre>keytool -genkey -alias YOURALIAS -keystore YOURSTORE 
-keypass KEYPASS -dname &quot;cn=YOUR NAME&quot; -storepass STOREPASS</pre>
<pre>jarsigner -keystore YOURSTORE -storepass STOREPASS -keypass KEYPASS 
-signedjar SIGNEDJAR.jar ORIGJAR.jar YOURALIAS</pre>
<pre>keytool -export -keystore YOURSTORE -storepass STOREPASS 
-alias YOURALIAS -file YOURCERT.cer</pre>
<p>Just replace what&#8217;s in capitals for your own values, and it should work happily.</p>
<p>** NOTICE: Wordpress is one big failure at wordwrapping. I had to split each of these into two lines. The second line should still be on the first line in the command prompt, and there should be a space between &#8220;YOURSTORE -keypass&#8221; like that.</p>
]]></content:encoded>
			<wfw:commentRss>http://matt-shaffer.com/blog/2009/01/10/signing-java-jar-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple XOR encryption in Java</title>
		<link>http://matt-shaffer.com/blog/2008/12/24/simple-xor-encryption-in-java/</link>
		<comments>http://matt-shaffer.com/blog/2008/12/24/simple-xor-encryption-in-java/#comments</comments>
		<pubDate>Wed, 24 Dec 2008 05:52:16 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[encryption]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[xor]]></category>

		<guid isPermaLink="false">http://matt-shaffer.com/?p=31</guid>
		<description><![CDATA[<br/>So, a long time ago (probably 2 years), I created 2 functions using the GameMaker engine that did super simple XOR encryption. XOR encryption is often debatable as being true encryption or not; but I call it encryption anyway. It&#8217;s easy to crack and should NOT be used for sensitive data, there are stronger methods [...]]]></description>
			<content:encoded><![CDATA[<br/><p>So, a long time ago (probably 2 years), I created 2 functions using the GameMaker engine that did super simple XOR encryption. XOR encryption is often debatable as being true encryption or not; but I call it encryption anyway. It&#8217;s easy to crack and should NOT be used for sensitive data, there are stronger methods out there. Now, onto the simple and short source.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p312"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
</pre></td><td class="code" id="p31code2"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> xorEnc<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> encKey, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> toEnc<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">/*
            Usage: str = xorEnc(integer_key,string_to_encrypt);
            Created by Matthew Shaffer (matt-shaffer.com)
        */</span>
        <span style="color: #000066; font-weight: bold;">int</span> t<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
        <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> s1<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
        <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> tog<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>encKey<span style="color: #339933;">&gt;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">while</span><span style="color: #009900;">&#40;</span>t <span style="color: #339933;">&lt;</span> toEnc.<span style="color: #006633;">length</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000066; font-weight: bold;">int</span> a<span style="color: #339933;">=</span>toEnc.<span style="color: #006633;">charAt</span><span style="color: #009900;">&#40;</span>t<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000066; font-weight: bold;">int</span> c<span style="color: #339933;">=</span>a <span style="color: #339933;">^</span> encKey<span style="color: #339933;">;</span>
                <span style="color: #000066; font-weight: bold;">char</span> d<span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">char</span><span style="color: #009900;">&#41;</span>c<span style="color: #339933;">;</span>
                tog<span style="color: #339933;">=</span>tog<span style="color: #339933;">+</span>d<span style="color: #339933;">;</span>
                t<span style="color: #339933;">++;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">return</span> tog<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> xorEncStr<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> encKey, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> toEnc<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">/*
            Usage: str = xorEnc(string_key,string_to_encrypt);
            Created by Matthew Shaffer (matt-shaffer.com)
        */</span>
        <span style="color: #000066; font-weight: bold;">int</span> t<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> encKeyI<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">while</span><span style="color: #009900;">&#40;</span>t <span style="color: #339933;">&lt;</span> encKey.<span style="color: #006633;">length</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            encKeyI<span style="color: #339933;">+=</span>encKey.<span style="color: #006633;">charAt</span><span style="color: #009900;">&#40;</span>t<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            t<span style="color: #339933;">+=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">return</span> xorEnc<span style="color: #009900;">&#40;</span>encKeyI,toEnc<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>I&#8217;m not going to bother explaing much how these two functions work. Using them is simple and you should read the comments in the functions, and I&#8217;m pretty sure all you want to do is rip them anyway. xorEncStr basically converts the string key you provide it into an integer and passes it to xorEnc. Both of the above functions have been tested to work!</p>
]]></content:encoded>
			<wfw:commentRss>http://matt-shaffer.com/blog/2008/12/24/simple-xor-encryption-in-java/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Converting a String to int[] in Java</title>
		<link>http://matt-shaffer.com/blog/2008/12/21/converting-a-string-to-int-in-java/</link>
		<comments>http://matt-shaffer.com/blog/2008/12/21/converting-a-string-to-int-in-java/#comments</comments>
		<pubDate>Sun, 21 Dec 2008 13:04:20 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://matt-shaffer.com/?p=10</guid>
		<description><![CDATA[<br/>There are just some things that google can never tell you, and no matter how hard you try to search for it you may never find what you are looking for. That happened to me when I tried to find out how to convert a String to an Integer array in Java. So, here&#8217;s the [...]]]></description>
			<content:encoded><![CDATA[<br/><p>There are just some things that google can never tell you, and no matter how hard you try to search for it you may never find what you are looking for. That happened to me when I tried to find out how to convert a String to an Integer array in Java. So, here&#8217;s the simple function that will do this:</p>

<div class="wp_codebox"><table width="100%" ><tr id="p104"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code" id="p10code4"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> strToInt <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> inp<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> toRet <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span>inp.<span style="color: #006633;">length</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
   <span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
   <span style="color: #000000; font-weight: bold;">while</span><span style="color: #009900;">&#40;</span>i <span style="color: #339933;">&lt;</span> inp.<span style="color: #006633;">length</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      toRet<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#41;</span>inp.<span style="color: #006633;">charAt</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      i<span style="color: #339933;">++;</span>
   <span style="color: #009900;">&#125;</span>
   <span style="color: #000000; font-weight: bold;">return</span> toRet<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>This function goes through every character of the string and gets the integer value of the character and adds it to the integer array. When it&#8217;s done adding everything, it returns the integer array with the same length as the string.</p>
<p>(PS: Sorry for unindented code; I&#8217;ll have to find a better code plugin..)</p>
]]></content:encoded>
			<wfw:commentRss>http://matt-shaffer.com/blog/2008/12/21/converting-a-string-to-int-in-java/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
