<?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>Tech.It.2.Me-&#62;{By.Anton.Perez} &#187; How-to</title>
	<atom:link href="http://antonperez.com/category/how-to/feed/" rel="self" type="application/rss+xml" />
	<link>http://antonperez.com</link>
	<description>Technical satisfaction guaranteed...</description>
	<lastBuildDate>Thu, 29 Jul 2010 23:57:34 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Hash class using System.Security.Cryptography</title>
		<link>http://antonperez.com/2010/07/29/hash-class-from-system-security-cryptography/</link>
		<comments>http://antonperez.com/2010/07/29/hash-class-from-system-security-cryptography/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 23:57:20 +0000</pubDate>
		<dc:creator>anton</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[How-to]]></category>

		<guid isPermaLink="false">http://antonperez.com/2010/07/29/hash-class-from-system-security-cryptography/</guid>
		<description><![CDATA[Adding for archival purposes…
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Security.Cryptography;

namespace Classes
{
    public class Hash
    {
        public Hash()
        { }

        #region Hash Choices
        [...]]]></description>
			<content:encoded><![CDATA[<p>Adding for archival purposes…</p>
<pre class="code"><span style="color: blue">using </span>System;
<span style="color: blue">using </span>System.Collections.Generic;
<span style="color: blue">using </span>System.Linq;
<span style="color: blue">using </span>System.Web;
<span style="color: blue">using </span>System.Security.Cryptography;

<span style="color: blue">namespace </span>Classes
{
    <span style="color: blue">public class </span><span style="color: #2b91af">Hash
    </span>{
        <span style="color: blue">public </span>Hash()
        { }

        <span style="color: blue">#region </span>Hash Choices
        <span style="color: gray">/// &lt;summary&gt;</span><span style="color: green">The wanted hash function.</span><span style="color: gray">&lt;/summary&gt;
        </span><span style="color: blue">public enum </span><span style="color: #2b91af">HashType </span>: <span style="color: blue">int
        </span>{
            <span style="color: gray">/// &lt;summary&gt;</span><span style="color: green">MD5 Hashing</span><span style="color: gray">&lt;/summary&gt;
            </span>MD5,
            <span style="color: gray">/// &lt;summary&gt;</span><span style="color: green">SHA1 Hashing</span><span style="color: gray">&lt;/summary&gt;
            </span>SHA1,
            <span style="color: gray">/// &lt;summary&gt;</span><span style="color: green">SHA256 Hashing</span><span style="color: gray">&lt;/summary&gt;
            </span>SHA256,
            <span style="color: gray">/// &lt;summary&gt;</span><span style="color: green">SHA384 Hashing</span><span style="color: gray">&lt;/summary&gt;
            </span>SHA384,
            <span style="color: gray">/// &lt;summary&gt;</span><span style="color: green">SHA512 Hashing</span><span style="color: gray">&lt;/summary&gt;
            </span>SHA512
        } <span style="color: green">/* HashType */
        </span><span style="color: blue">#endregion

        #region </span>Public Methods
        <span style="color: gray">/// &lt;summary&gt;</span><span style="color: green">Generates the hash of a text.</span><span style="color: gray">&lt;/summary&gt;
        /// &lt;param name=&quot;strPlain&quot;&gt;</span><span style="color: green">The text of which to generate a hash of.</span><span style="color: gray">&lt;/param&gt;
        /// &lt;param name=&quot;hshType&quot;&gt;</span><span style="color: green">The hash function to use.</span><span style="color: gray">&lt;/param&gt;
        /// &lt;returns&gt;</span><span style="color: green">The hash as a hexadecimal string.</span><span style="color: gray">&lt;/returns&gt;
        </span><span style="color: blue">public static string </span>GetHash(<span style="color: blue">string </span>strPlain, <span style="color: #2b91af">HashType </span>hshType)
        {
            <span style="color: blue">string </span>strRet;
            <span style="color: blue">switch </span>(hshType)
            {
                <span style="color: blue">case </span><span style="color: #2b91af">HashType</span>.MD5:
                    strRet = GetMD5(strPlain);
                    <span style="color: blue">break</span>;
                <span style="color: blue">case </span><span style="color: #2b91af">HashType</span>.SHA1:
                    strRet = GetSHA1(strPlain);
                    <span style="color: blue">break</span>;
                <span style="color: blue">case </span><span style="color: #2b91af">HashType</span>.SHA256:
                    strRet = GetSHA256(strPlain);
                    <span style="color: blue">break</span>;
                <span style="color: blue">case </span><span style="color: #2b91af">HashType</span>.SHA384:
                    strRet = GetSHA384(strPlain);
                    <span style="color: blue">break</span>;
                <span style="color: blue">case </span><span style="color: #2b91af">HashType</span>.SHA512:
                    strRet = GetSHA512(strPlain);
                    <span style="color: blue">break</span>;
                <span style="color: blue">default</span>:
                    strRet = <span style="color: #a31515">&quot;Invalid HashType&quot;</span>;
                    <span style="color: blue">break</span>;
            }
            <span style="color: blue">return </span>strRet;
        } <span style="color: green">/* GetHash */

        </span><span style="color: gray">/// &lt;summary&gt;</span><span style="color: green">Checks a text with a hash.</span><span style="color: gray">&lt;/summary&gt;
        /// &lt;param name=&quot;strOriginal&quot;&gt;</span><span style="color: green">The text to compare the hash against.</span><span style="color: gray">&lt;/param&gt;
        /// &lt;param name=&quot;strHash&quot;&gt;</span><span style="color: green">The hash to compare against.</span><span style="color: gray">&lt;/param&gt;
        /// &lt;param name=&quot;hshType&quot;&gt;</span><span style="color: green">The type of hash.</span><span style="color: gray">&lt;/param&gt;
        /// &lt;returns&gt;</span><span style="color: green">True if the hash validates, false otherwise.</span><span style="color: gray">&lt;/returns&gt;
        </span><span style="color: blue">public static bool </span>CheckHash(<span style="color: blue">string </span>strOriginal, <span style="color: blue">string </span>strHash, <span style="color: #2b91af">HashType </span>hshType)
        {
            <span style="color: blue">string </span>strOrigHash = GetHash(strOriginal, hshType);
            <span style="color: blue">return </span>(strOrigHash == strHash);
        } <span style="color: green">/* CheckHash */
        </span><span style="color: blue">#endregion

        #region </span>Hashers
        <span style="color: blue">private static string </span>GetMD5(<span style="color: blue">string </span>strPlain)
        {
            <span style="color: #2b91af">UnicodeEncoding </span>UE = <span style="color: blue">new </span><span style="color: #2b91af">UnicodeEncoding</span>();
            <span style="color: blue">byte</span>[] HashValue, MessageBytes = UE.GetBytes(strPlain);
            <span style="color: #2b91af">MD5 </span>md5 = <span style="color: blue">new </span><span style="color: #2b91af">MD5CryptoServiceProvider</span>();
            <span style="color: blue">string </span>strHex = <span style="color: #a31515">&quot;&quot;</span>;

            HashValue = md5.ComputeHash(MessageBytes);
            <span style="color: blue">foreach </span>(<span style="color: blue">byte </span>b <span style="color: blue">in </span>HashValue)
            {
                strHex += <span style="color: #2b91af">String</span>.Format(<span style="color: #a31515">&quot;{0:x2}&quot;</span>, b);
            }
            <span style="color: blue">return </span>strHex;
        } <span style="color: green">/* GetMD5 */

        </span><span style="color: blue">private static string </span>GetSHA1(<span style="color: blue">string </span>strPlain)
        {
            <span style="color: #2b91af">UnicodeEncoding </span>UE = <span style="color: blue">new </span><span style="color: #2b91af">UnicodeEncoding</span>();
            <span style="color: blue">byte</span>[] HashValue, MessageBytes = UE.GetBytes(strPlain);
            <span style="color: #2b91af">SHA1Managed </span>SHhash = <span style="color: blue">new </span><span style="color: #2b91af">SHA1Managed</span>();
            <span style="color: blue">string </span>strHex = <span style="color: #a31515">&quot;&quot;</span>;

            HashValue = SHhash.ComputeHash(MessageBytes);
            <span style="color: blue">foreach </span>(<span style="color: blue">byte </span>b <span style="color: blue">in </span>HashValue)
            {
                strHex += <span style="color: #2b91af">String</span>.Format(<span style="color: #a31515">&quot;{0:x2}&quot;</span>, b);
            }
            <span style="color: blue">return </span>strHex;
        } <span style="color: green">/* GetSHA1 */

        </span><span style="color: blue">private static string </span>GetSHA256(<span style="color: blue">string </span>strPlain)
        {
            <span style="color: #2b91af">UnicodeEncoding </span>UE = <span style="color: blue">new </span><span style="color: #2b91af">UnicodeEncoding</span>();
            <span style="color: blue">byte</span>[] HashValue, MessageBytes = UE.GetBytes(strPlain);
            <span style="color: #2b91af">SHA256Managed </span>SHhash = <span style="color: blue">new </span><span style="color: #2b91af">SHA256Managed</span>();
            <span style="color: blue">string </span>strHex = <span style="color: #a31515">&quot;&quot;</span>;

            HashValue = SHhash.ComputeHash(MessageBytes);
            <span style="color: blue">foreach </span>(<span style="color: blue">byte </span>b <span style="color: blue">in </span>HashValue)
            {
                strHex += <span style="color: #2b91af">String</span>.Format(<span style="color: #a31515">&quot;{0:x2}&quot;</span>, b);
            }
            <span style="color: blue">return </span>strHex;
        } <span style="color: green">/* GetSHA256 */

        </span><span style="color: blue">private static string </span>GetSHA384(<span style="color: blue">string </span>strPlain)
        {
            <span style="color: #2b91af">UnicodeEncoding </span>UE = <span style="color: blue">new </span><span style="color: #2b91af">UnicodeEncoding</span>();
            <span style="color: blue">byte</span>[] HashValue, MessageBytes = UE.GetBytes(strPlain);
            <span style="color: #2b91af">SHA384Managed </span>SHhash = <span style="color: blue">new </span><span style="color: #2b91af">SHA384Managed</span>();
            <span style="color: blue">string </span>strHex = <span style="color: #a31515">&quot;&quot;</span>;

            HashValue = SHhash.ComputeHash(MessageBytes);
            <span style="color: blue">foreach </span>(<span style="color: blue">byte </span>b <span style="color: blue">in </span>HashValue)
            {
                strHex += <span style="color: #2b91af">String</span>.Format(<span style="color: #a31515">&quot;{0:x2}&quot;</span>, b);
            }
            <span style="color: blue">return </span>strHex;
        } <span style="color: green">/* GetSHA384 */

        </span><span style="color: blue">private static string </span>GetSHA512(<span style="color: blue">string </span>strPlain)
        {
            <span style="color: #2b91af">UnicodeEncoding </span>UE = <span style="color: blue">new </span><span style="color: #2b91af">UnicodeEncoding</span>();
            <span style="color: blue">byte</span>[] HashValue, MessageBytes = UE.GetBytes(strPlain);
            <span style="color: #2b91af">SHA512Managed </span>SHhash = <span style="color: blue">new </span><span style="color: #2b91af">SHA512Managed</span>();
            <span style="color: blue">string </span>strHex = <span style="color: #a31515">&quot;&quot;</span>;

            HashValue = SHhash.ComputeHash(MessageBytes);
            <span style="color: blue">foreach </span>(<span style="color: blue">byte </span>b <span style="color: blue">in </span>HashValue)
            {
                strHex += <span style="color: #2b91af">String</span>.Format(<span style="color: #a31515">&quot;{0:x2}&quot;</span>, b);
            }
            <span style="color: blue">return </span>strHex;
        } <span style="color: green">/* GetSHA512 */
        </span><span style="color: blue">#endregion
    </span>}
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://antonperez.com/2010/07/29/hash-class-from-system-security-cryptography/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reference for jsSHA</title>
		<link>http://antonperez.com/2010/07/28/reference-for-jssha/</link>
		<comments>http://antonperez.com/2010/07/28/reference-for-jssha/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 02:16:30 +0000</pubDate>
		<dc:creator>anton</dc:creator>
				<category><![CDATA[General Development]]></category>
		<category><![CDATA[How-to]]></category>
		<category><![CDATA[Resource]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://antonperez.com/2010/07/28/reference-for-jssha/</guid>
		<description><![CDATA[jsSHA - A JavaScript implementation of the complete Secure Hash Standard family
            (SHA-1, SHA-224, SHA-256, SHA-384, and SHA-512) by Brian Turek

About
-------------------------
jsSHA is a javaScript implementation of the complete Secure Hash Algorithm family as defined
by FIPS PUB 180-2 (http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf)

With the slow phasing out of MD5 [...]]]></description>
			<content:encoded><![CDATA[<pre>jsSHA - A JavaScript implementation of the complete Secure Hash Standard family
            (SHA-1, SHA-224, SHA-256, SHA-384, and SHA-512) by Brian Turek

About
-------------------------
jsSHA is a javaScript implementation of the complete Secure Hash Algorithm family as defined
by FIPS PUB 180-2 (http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf)

With the slow phasing out of MD5 as the standard hash to use in web applications, a client-side
implementation of the complete Secure Hash Standard family was needed.  Due to SHA-384 and SHA-512's
use of 64-bit values throughout the algorithm, JavaScript can not easily natively support the calculation
of these hashes.  As a result, a bit of hacking had to be done to make sure the values behaved themselves.
SHA-224 was added to the Secure Hash Standard family on 25 February 2004 so it was also included in this
package.

Files
-------------------------
src/sha.js
The complete SHA implementation

src/sha1.js
A smaller/web friendly implementation of only SHA-1.

src/sha256.js
A smaller/web friendly implementation of only SHA-224 and SHA-256.

src/sha512.js
A smaller/web friendly implementation of only SHA-384 and SHA-512.

src/wrapper.js
Wrapper functions to be added to the above script files if the jsSHA 0.1 interface is desired

test/test.html
A test page that calculates various hashes and has their correct values.

Usage
-------------------------
Include the desired JavaScript file (sha.js, sha1.js, sha256.js, or sha512.js) in your header (sha.js used below):
&lt;script type=&quot;text/javascript&quot; src=&quot;/path/to/sha.js&quot;&gt;&lt;/script&gt;

Instantiate a new jsSHA object with your string to be hashed as the only parameter.  Then, call getHash with the desired
hash variant (SHA-1, SHA-224, SHA-256, SHA-384, or SHA-512) and output type (HEX or B64).  In the example below,
&quot;This is a Test&quot; and &quot;SHA-512&quot; were used as the string to be hashed and variant respectively.

var shaObj = new jsSHA(&quot;This is a Test&quot;);
var hash = shaObj.getHash(&quot;SHA-512&quot;, &quot;HEX&quot;);

NOTE: If you are using sha1.js, omit the SHA variant parameter as there is only one option.

Since the interface was changed drastically from 0.1 to 1.0, src/wrapper.js is included in case the old interface is desired.
Simply copy and paste the correct functions from wrapper.js to the bottom of the used jsSHA JS file.

Contact Info
-------------------------
The project's website is located at http://jssha.sourceforge.net/</pre>
]]></content:encoded>
			<wfw:commentRss>http://antonperez.com/2010/07/28/reference-for-jssha/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get file version remotely using PowerShell</title>
		<link>http://antonperez.com/2010/07/22/get-file-version-remotely-using-powershell/</link>
		<comments>http://antonperez.com/2010/07/22/get-file-version-remotely-using-powershell/#comments</comments>
		<pubDate>Thu, 22 Jul 2010 23:12:18 +0000</pubDate>
		<dc:creator>anton</dc:creator>
				<category><![CDATA[How-to]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://antonperez.com/2010/07/22/get-file-version-remotely-using-powershell/</guid>
		<description><![CDATA[PS C:\&#62; gc servers.txt &#124; foreach { [system.diagnostics.fileversioninfo]::getversioninfo($_) }
]]></description>
			<content:encoded><![CDATA[<p>PS C:\&gt; gc servers.txt | foreach { [system.diagnostics.fileversioninfo]::getversioninfo($_) }</p>
]]></content:encoded>
			<wfw:commentRss>http://antonperez.com/2010/07/22/get-file-version-remotely-using-powershell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tips on how to prolong your laptop battery life</title>
		<link>http://antonperez.com/2010/07/19/tips-on-how-to-prolong-your-laptop-battery-life/</link>
		<comments>http://antonperez.com/2010/07/19/tips-on-how-to-prolong-your-laptop-battery-life/#comments</comments>
		<pubDate>Mon, 19 Jul 2010 20:29:35 +0000</pubDate>
		<dc:creator>anton</dc:creator>
				<category><![CDATA[Gadgets]]></category>
		<category><![CDATA[How-to]]></category>
		<category><![CDATA[Resource]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://antonperez.com/2010/07/19/tips-on-how-to-prolong-your-laptop-battery-life/</guid>
		<description><![CDATA[This applies to any device that uses lithium ion batteries (i.e. laptops, smartphones).
Battery

For lithium ion batteries, you do not need to discharge them fully and recharge constantly. Since they don&#8217;t have the same &#34;memory&#34; as older nickel-metal hydride batteries, it is actually better to discharge a lithium ion only partially (10 to 20%) before recharging. [...]]]></description>
			<content:encoded><![CDATA[<p>This applies to any device that uses lithium ion batteries (i.e. laptops, smartphones).</p>
<p><strong><u>Battery</u></strong></p>
<ol>
<li>For lithium ion batteries, you do not need to discharge them fully and recharge constantly. Since they don&#8217;t have the same &quot;memory&quot; as older nickel-metal hydride batteries, it is actually better to discharge a lithium ion only partially (10 to 20%) before recharging. You need to do a full discharge only about every 30 charges (usually around every 2 to 3 weeks).</li>
<li>Consider taking your battery out when using your laptop plugged into AC power. Just make sure to keep the contacts clean. If you need to clean them, use a lint-free cloth moistened with rubbing alcohol every couple of months.</li>
</ol>
<p><strong><u>Software &amp; Hardware</u></strong></p>
<ol>
<li>Defrag your hard drive regularly</li>
<li>Dim your screen to the lowest level you can tolerate</li>
<li>Close unused programs running in the background</li>
<li>Disable WIFI when not in use.</li>
<li>Hibernate your computer, not standby.</li>
</ol>
<p><strong><u>Environment</u></strong></p>
<ol>
<li>Avoid propping your laptop on a pillow, blanket, or other soft surface that can heat up or block cooling fans.</li>
<li>Clean your desk. It sounds strange, but if you have a dusty, dirty desk, that dust will get into the vents and clog the cooling fan. Once the dust is inside your laptop, it is much harder to remove. You can try blasting it out with canned air, but you run the risk of damaging internal components. You can also remove the vent and clean out the grit, but remember that taking apart your laptop can void the warranty. So clean your desk at least once a week, if not daily.</li>
<li>Try not to store your laptop in a place where the air temperature exceeds 80 degrees Fahrenheit, such as a hot car or an outdoor patio. And if your laptop heats up or is cold, let it return to room temperature before starting up.</li>
<li>Use a cooling pad when using a notebook computer on your lap.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://antonperez.com/2010/07/19/tips-on-how-to-prolong-your-laptop-battery-life/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fix to &quot;The handle is invalid&quot; error when ASP.NET writes to the Eventlogs</title>
		<link>http://antonperez.com/2010/07/12/fix-to-the-handle-is-invalid-error-when-asp-net-writes-to-the-eventlogs/</link>
		<comments>http://antonperez.com/2010/07/12/fix-to-the-handle-is-invalid-error-when-asp-net-writes-to-the-eventlogs/#comments</comments>
		<pubDate>Mon, 12 Jul 2010 20:50:19 +0000</pubDate>
		<dc:creator>anton</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[General Development]]></category>
		<category><![CDATA[How-to]]></category>

		<guid isPermaLink="false">http://antonperez.com/2010/07/12/fix-to-the-handle-is-invalid-error-when-asp-net-writes-to-the-eventlogs/</guid>
		<description><![CDATA[Have you ever come across the error below with one of your ASP.NET web apps that is trying to write to the Eventlogs? If so, read on&#8230; 
 
By default the ASPNET user cannot access the existing eventlogs categories. To resolve this, you must set the permissions in the Eventlog key in the registry: 

Launch [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever come across the error below with one of your ASP.NET web apps that is trying to write to the Eventlogs? If so, read on&#8230; </p>
<p><a href="http://antonperez.com/wp-content/uploads/2010/07/image1.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://antonperez.com/wp-content/uploads/2010/07/image_thumb1.png" width="244" height="117" /></a> </p>
<p>By default the ASPNET user cannot access the existing eventlogs categories. To resolve this, you must set the permissions in the Eventlog key in the registry: </p>
<ol>
<li>Launch RegEdit. </li>
<li>Navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\. </li>
<li>From the menu, select Edit-&gt;Permissions. </li>
<li>Click the Add button and write ASPNET (if ASP.NET is running under a different User ID, use that ID instead). </li>
<li>Click OK. </li>
<li>Select the newly added user from the list (ASP.NET Machine User by default). </li>
<li>Click on Full Control in the Allow column. 8. Click OK.</li>
</ol>
<p>More info <a href="http://support.microsoft.com/kb/842795">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://antonperez.com/2010/07/12/fix-to-the-handle-is-invalid-error-when-asp-net-writes-to-the-eventlogs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
