<?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>Christian's Blog &#187; Tutorials</title>
	<atom:link href="http://christianbeikov.at/category/tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>http://christianbeikov.at</link>
	<description>This is the blog of the Main-Programmer of Blazebit, Christian Beikov</description>
	<lastBuildDate>Mon, 15 Feb 2010 07:58:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Design Patterns &#8211; Abstraction with PDO</title>
		<link>http://christianbeikov.at/2010/01/design-patterns-abstraction-with-pdo/</link>
		<comments>http://christianbeikov.at/2010/01/design-patterns-abstraction-with-pdo/#comments</comments>
		<pubDate>Tue, 12 Jan 2010 09:58:42 +0000</pubDate>
		<dc:creator>Christian Beikov</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://christianbeikov.at/?p=130</guid>
		<description><![CDATA[Today I want to write about some design patterns. There are really many out there and I want to summarize them a bit for you.
I will not write about design patterns of a specific language but for general. Many of them are really usefull!]]></description>
			<content:encoded><![CDATA[<p>Today I want to write about some design patterns. There are really many out there and I want to summarize them a bit for you.<br />
I will not write about design patterns of a specific language but for general. Many of them are really usefull!</p>
<p>Don&#8217;t you have sometimes the problem that you don&#8217;t know how to begin when you are programming a class or so?<br />
You are thinking and thinking of how you could design the class or class hierachy (Polymorphism) that it is easy to understand, lightweight, not so much time consuming to implement it and so on&#8230;<br />
Then after hours of thinking you have a solution but you are never sure if it&#8217;s really okay like that. You just implement the class and if something does not fit you have to change it.<br />
But now think of it, is that really reasonable? You put so much time into designing a class or class hierachy but for what? That you can change everything in let&#8217;s say 200 files where you used that class? That shouldn&#8217;t be!</p>
<p>As an example we take a communication with a database. The standard in PHP is to use MySQL, that&#8217;s okay but what happens if you want to use PostgresSQL now? You maybe will have to change every query statement because it can be case that in this dialect something is written different than in the other. So it&#8217;s hard for use to change the database system just by replacing the connect call to a new one. We not only have the problem with the SQL statements, but you have to change the calls of the SQL statements too.</p>
<p>Here you can see a PHP example to know what I mean by that.</p>
<pre class="php" name="code">// Using PostgresSQL
$conString= "host=localhost port=5432 ".
                 "dbname=DATABASE ".
                 "user=USERNAME ".
                 "password=PASSWORD";
$connection = pg_connect($conString);

$sql = "SELECT field FROM table WHERE field = '$something' ";
$result = pg_query($connection, $sql);
$fetch = pg_fetch_row($result);

pg_close($connection);

// -------------------
// Using MySQL
$connection = mysql_connect("localhost", "USERNAME", "PASSWORD");
mysql_select_db ("DATABASE", $connection); 

$sql = "SELECT field FROM table WHERE field = '$something' ";
$result = mysql_query($sql, $connection);
$fetch = mysql_fetch_row($result);

mysql_close($connection);</pre>
<p>Here we don&#8217;t have a problem with the SQL statement, but what happens if you use the function mysql_query for about 500 times in 200 different files? Try to change that! Somebody will probably say now that there are tools which you can use to make such mass operations, but that&#8217;s not the point! What do you want to do now if we have a SQL statement that is not compatible to other SQL systems? You have to change nearly everything in your application to correct that. It&#8217;s really time consuming, so we should try to get to find a solution.</p>
<p>First of all think about something like a DAO class. DAO (Data Access Object) is really nice and saves you a lot of time. In a DAO class you make methods which give you back objects as result. Let&#8217;s say you have something like showing news on a website. Then make a method getNews() and just use that method everywhere you need the news. You can define parameters for that method and so on but you always get let&#8217;s say an array of news objects from that method. That&#8217;s really nice because you don&#8217;t have to think about what the name of the column was and so on, your IDE will suggest the methods and variables. This kind of system is very simmilar in some points to an ORM (Object Relation Mapping) system which don&#8217;t has any foreign keys but the objects which is related to the foreign keys. Of course you still have to implement data classes for each table but this will help you a lot.</p>
<p>So now we have a DAO object which handles the connection to the database and provides methods which give us arrays of objects but we still have the compability problem to other systems, for this I suggest to use PDO (PHP Data Object) in PHP. In Java we have JDBC, in .NET Linq and so on. With PDO you have only one class which uses drivers to communicate with the database systems, you only have methods like query() and fetch() so we don&#8217;t have to rename the calls any more.</p>
<pre class="php" name="code">// Using PDO
$connectionString = "mysql:host=localhost;dbname=DATABASE";
$user = "USERNAME";
$pass = "PASSWORD";
$pdo = new PDO($connectionString, $user, $pass);

$sql = "SELECT field FROM table WHERE field = '$something' ";
$stmt= $pdo->query($sql);
$fetch = $stmt->fetch(PDO::FETCH_NUM);

$stmt->closeCursor();
</pre>
<p>As you can see, it&#8217;s easy and the best is, if you change the database system, you just have to change the connection string!</p>
<p>I hope you enjoyed this article and you will go on reading my texts about design patterns!</p>
]]></content:encoded>
			<wfw:commentRss>http://christianbeikov.at/2010/01/design-patterns-abstraction-with-pdo/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Cracking Hashes</title>
		<link>http://christianbeikov.at/2009/10/cracking-hashes/</link>
		<comments>http://christianbeikov.at/2009/10/cracking-hashes/#comments</comments>
		<pubDate>Sun, 18 Oct 2009 22:01:52 +0000</pubDate>
		<dc:creator>Christian Beikov</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://christianbeikov.at/?p=68</guid>
		<description><![CDATA[Today I found a website which really scared me! I want to share that with you because I think it's important for everyone who ever dealed with passwords.
I looked for something like a SHA256 Cracker on google to be sure that it's not crackable.]]></description>
			<content:encoded><![CDATA[<p>Today I found a website which really scared me! I want to share that with you because I think it&#8217;s important for everyone who ever dealed with passwords.<br />
I looked for something like a SHA256 Cracker on google to be sure that it&#8217;s not crackable.<br />
<br />
First of all some information on SHA256, it was developed by the NSA (National Security Agency). SHA is the abbreviation for Secure Hash Algorithm and is one of the most secure hash algorithms.<br />
A SHA256 hash has 64 hex characters so if you want to save that into you database you will need a 64 byte for a hash. With growing technologies like GPU Computing you as a programmer have to use more complex algorithms to be sure that the hashed passwords can&#8217;t be cracked.<br />
<br />
Now to the point, <strong><a href="http://lmcrack.com">LM Reverse</a></strong> and <strong><a href="http://hash.db.hk">Hash.Db.Hk</a></strong> have big databases which contain already many SHA256 hashes. Mostly they can only crack simple ones but the new technologies will help the crackers to guess or maybe even reverse hashes.<br />
<br />
I would really recommend you all to use SHA512. Performance should not be a reason for you to not use SHA512. Here is a little comparison between the hashes, all calculation times are in milliseconds. The times were measured on a laptop, so on a productive webserver it is even faster!</p>
<table style="border: 1px solid; width: 250px;" border="1" cellspacing="0">
<thead>
<tr>
<th>Hash</th>
<th>Calculation in ms</th>
</tr>
</thead>
<tbody>
<tr>
<td>md5</td>
<td>6.89</td>
</tr>
<tr>
<td>sha1</td>
<td>8.88</td>
</tr>
<tr>
<td>sha256</td>
<td>19.02</td>
</tr>
<tr>
<td>sha384</td>
<td>45.10</td>
</tr>
<tr>
<td>sha512</td>
<td>45.65</td>
</tr>
</tbody>
</table>
<p>These calculation times are from <strong><a href="http://at.php.net/manual/en/function.hash.php#89574">PHP.NET</a></strong> so as you can see SHA512 takes twice as long as SHA256 for calculation but your applications will be more secure!  SHA512 has 128 hex characters and I haven&#8217;t found any database yet which you can use to get the plaintext from a hash. The only way to crack a SHA512 is by using a password dictionary and for this I would recommend you to use a SALT.<br />
<br />
The SALT should contain special characters like &#8216;$&#8217;, &#8216;%&#8217;, &#8216;&amp;&#8217; and so on. With the special characters it is much harder for a cracker to crack the hashes with dictionaries!<br />
<br />
Here an example of hashing with SHA512 and a SALT.</p>
<pre name="code" class="php">
	$Algo = "sha512";
	$Salt = "!§$%&#038;/()=?";
	$Password = "Hello";

	echo $Password;
	echo hash($Algo, $Salt.$Password.$Salt);
</pre>
<p>This will give you the following output&#8230;</p>
<blockquote><p>
Hello<br />
009afe8d638e00b1b51fbe33666b337d57d9bc3819ec6ceba3e5dc5e984390cd95979994a02cb&#8230;
</p></blockquote>
<p>Nice heh? 128 hex characters! =D<br />
I hope you enjoyed this article and you will try to use SHA512 instead of MD5, SHA1 or SHA256!</p>
]]></content:encoded>
			<wfw:commentRss>http://christianbeikov.at/2009/10/cracking-hashes/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Calling via TAPI</title>
		<link>http://christianbeikov.at/2009/10/calling-via-tapi/</link>
		<comments>http://christianbeikov.at/2009/10/calling-via-tapi/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 13:17:13 +0000</pubDate>
		<dc:creator>Christian Beikov</dc:creator>
				<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://christianbeikov.at/?p=66</guid>
		<description><![CDATA[Some days ago i finished a project which was about using the TAPI. I will give you a short introduction into TAPI and give my example for that project.]]></description>
			<content:encoded><![CDATA[<p>Some days ago i finished a project which was about using the TAPI. I will give you a short introduction into TAPI and give my example for that project.</p>
<p>Here a short description about what TAPI is.<br />
The Telephony Application Programming Interface (TAPI) is a Microsoft Windows API, which provides computer telephony integration and enables PCs running Microsoft Windows to use telephone services.<br />
With it you can control a telephone which uses this TAPI. You can listen for calls, make calls and many other things.</p>
<p>For this project I only needed to make a call by clicking on a number in the browser, of course it should work in every browser.<br />
First of all we will check how to get the number from the browser to the telephone. A client has installed the telephone so we need a client solution. So what can we do on the client to pass a number as parameter via TAPI to a telephone? Probably via desktop command line application which is using the TAPI-Library.<br />
Okay now we know how will communicate with the telephone, but how will that application get the number from browser?<br />
On way could be via Javascript, which is probably not realizable. The other choice and I think that&#8217;s the last option we have is to register a new protocol, like HTTP. So we have for example something like &#8220;phone:0123456789&#8243; instead of &#8220;http://&#8230;&#8221;.</p>
<p>How can we register such a protocol now?<br />
I don&#8217;t know how to do that on UNIX Systems but on Windows we just need a registry entry!</p>
<blockquote><p>REGEDIT4</p>
<p>[HKEY_CLASSES_ROOT\PROTOCOL_NAME]<br />
@=&#8221;URL:PROTOCOL_NAME Protocol&#8221;<br />
&#8220;URL Protocol&#8221;=&#8221;"</p>
<p>[HKEY_CLASSES_ROOT\PROTOCOL_NAME\shell]<br />
[HKEY_CLASSES_ROOT\PROTOCOL_NAME\shell\open]<br />
[HKEY_CLASSES_ROOT\PROTOCOL_NAME\shell\open\command]<br />
@=&#8221;\&#8221;PATH_TO_EXE\&#8221; \&#8221;%1\&#8221;"</p></blockquote>
<p>By replacing the PROTOCOL_NAME with your own protocol and the PATH_TO_EXE with the absolute path to your exe file you can pass parameters to the program.</p>
<p><strong>tapi.reg</strong></p>
<blockquote><p>REGEDIT4</p>
<p>[HKEY_CLASSES_ROOT\phone]<br />
@=&#8221;URL:phone Protocol&#8221;<br />
&#8220;URL Protocol&#8221;=&#8221;"</p>
<p>[HKEY_CLASSES_ROOT\phone\shell]<br />
[HKEY_CLASSES_ROOT\phone\shell\open]<br />
[HKEY_CLASSES_ROOT\phone\shell\open\command]<br />
@=&#8221;\&#8221;C:\\TAPI\\TapiCall.exe\&#8221; \&#8221;%1\&#8221;"</p></blockquote>
<p>The %1 is for a parameter, you will get that parameter through the arguments in the main method.<br />
I have made a batch file which installs the the whole thing&#8230;</p>
<p><strong>install.bat</strong></p>
<blockquote><p>mkdir &#8220;C:\TAPI&#8221;<br />
copy Interop.TAPI3Lib.dll &#8220;C:\TAPI&#8221;<br />
copy TapiCall.exe &#8220;C:\TAPI&#8221;<br />
tapi.reg</p></blockquote>
<p>This batch file creates the directory TAPI on C: and copies the files which are needed and finally executes the regedit file.<br />
Now we just need the program which sends the number to the TAPI-Device.<br />
I decided to use C# because I found a TAPI Library for C# and of course because I know C# really good.<br />
It is easy to make programs with C#, you can be really fast and the community is really big.<br />
I used an example from Codeprojects to test the dialing process and the final solution look like that&#8230;</p>
<p><img src="http://farm3.static.flickr.com/2561/4010658439_d9eb838e61_o.png" alt="Mainmethod" /></p>
<p>Here you can see the main method which takes the main parameters and parses it.<br />
Don&#8217;t forget to include the TAPI-Library.</p>
<p><img src="http://farm3.static.flickr.com/2650/4011335064_9828c19a25_o.png" alt="Tapilib" /></p>
<p>Finally the call method which takes the number as string. Here i use the line which name contains &#8220;Agfeo&#8221; because the TAPI devices are from Agfeo.</p>
<p><img src="http://farm4.static.flickr.com/3496/4011423458_dfc2cd7b26_o.png" alt="Callmethod" /></p>
<p>When you click on a link now which has the value phone:123456 in the href attribute the program sends the number 123456 to the TAPI device to and starts the call.<br />
This is a browser independent solution of using your own protocol on a windows machine via browsers.<br />
I hope this helped you a bit if you try to make something like that.</p>
<p>The Visual Studio Project is in the source files which you can download here.</p>
<h2>
<p style="text-align: center;"><strong><a href="http://christianbeikov.at/wp-content/uploads/2009/10/TapiCall.zip">TAPI Project Files</a></strong></p>
</h2>
]]></content:encoded>
			<wfw:commentRss>http://christianbeikov.at/2009/10/calling-via-tapi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a Crypter Class</title>
		<link>http://christianbeikov.at/2009/09/creating-a-crypter-class/</link>
		<comments>http://christianbeikov.at/2009/09/creating-a-crypter-class/#comments</comments>
		<pubDate>Sat, 26 Sep 2009 13:00:03 +0000</pubDate>
		<dc:creator>Christian Beikov</dc:creator>
				<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.stun-design.com/?p=13</guid>
		<description><![CDATA[In this article I will explain how to create a PHP Class to encrypt end decrypt any data with a given password. It is object oriented programmed and uses in PHP existing algorithms.]]></description>
			<content:encoded><![CDATA[<p>Creating a Crypter Class</p>
<p>In this article I will explain how to create a PHP Class to encrypt end decrypt any data with a given password. It is object oriented programmed and uses in PHP existing algorithms.</p>
<h3 style="text-align: center;"><a href="http://net.tutsplus.com/tutorials/php/creating-a-crypter-class/">Read through the whole Tutorial at Nettuts</a></h3>
]]></content:encoded>
			<wfw:commentRss>http://christianbeikov.at/2009/09/creating-a-crypter-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
