<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Eran Nachum's Blog</title>
    <link>http://www.eranachum.com/</link>
    <description>www.eranachum.com - Implementing &amp; executing my thoughts...</description>
    <language>en-us</language>
    <copyright>Eran Nachum</copyright>
    <lastBuildDate>Sun, 02 Dec 2007 17:45:40 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 1.8.5223.2</generator>
    <managingEditor>eranachum@hotmail.com</managingEditor>
    <webMaster>eranachum@hotmail.com</webMaster>
    <item>
      <trackback:ping>http://www.eranachum.com/Trackback.aspx?guid=7d33d50f-e287-4cf0-83d1-696537a681cf</trackback:ping>
      <pingback:server>http://www.eranachum.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.eranachum.com/PermaLink,guid,7d33d50f-e287-4cf0-83d1-696537a681cf.aspx</pingback:target>
      <dc:creator>eranachum@hotmail.com (Eran Nachum)</dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
      Long time no written, I know.... I am quite busy these days at work and in my private
      time working on the web 2.0 startup with my colleagues.
   </p>
        <p>
      I received an email from <strong>Kevin Gao</strong>, which is the leading developer
      of a nice source control software that called SourceAnywhere Hosted of <a href="http://www.dynamsoft.com/" target="_blank">Dynamsoft</a> in
      order to check out their software tool. I decided to write about this tool, because
      this one is very suitable to me these days while working on my startup project. I
      actually needed a good source control in order to manage my code files properly.
   </p>
        <p>
      So, some conclusions regarding this tool, after working with it close to a month.
      Let start from the important thing for small developers like me - this tool is <strong>FREE </strong>to
      use for up to 3 users, which can be suitable for small to medium projects with low
      number of developers. 
   </p>
        <p>
      The second thing that was fine by me is the interface of this software, which is very
      similar to the Microsoft source control (admit it or not - I am a fan of it... ;)),
      this gave me great a familiar navigation ability between the functionality possibilities
      and indeed there are some nice possibilities and abilities, like: users and groups
      roles management and managing your code files (the usual functionality such as rollback,
      commit, check in/out etc.)
   </p>
        <p>
      The only disadvantage that I could think about here is a lack of files' state indicator.
      Dislike other source control tools that I worked with (like: <a href="http://msdn2.microsoft.com/en-us/library/3h0544kx(VS.80).aspx" target="_blank">Microsoft
      source safe control</a> which indicates a file content changes or file state directly
      in the Visual Studio environment or the <strong><a href="http://subversion.tigris.org/" target="_blank">SubVersion</a></strong> control
      system, which indicates the file's state in in the actual file system folder), this
      tool doesn't indicates it and this is kind of annoying.
   </p>
        <p>
      Generally I think this is a great tool to use it in order to manage your code version
      - again for small to  medium applications/projects.
   </p>
        <p>
      You can read about it and download it free of charge (for up to 3 users of course) <a href="http://www.dynamsoft.com/Products/SAWhosted_Overview.aspx" target="_blank">here</a>.
      Have fun!
   </p>
        <img width="0" height="0" src="http://www.eranachum.com/aggbug.ashx?id=7d33d50f-e287-4cf0-83d1-696537a681cf" />
      </body>
      <title>SourceAnywhere Hosted - My Proof of Concept</title>
      <guid>http://www.eranachum.com/PermaLink,guid,7d33d50f-e287-4cf0-83d1-696537a681cf.aspx</guid>
      <link>http://www.eranachum.com/PermaLink,guid,7d33d50f-e287-4cf0-83d1-696537a681cf.aspx</link>
      <pubDate>Sun, 02 Dec 2007 17:45:40 GMT</pubDate>
      <description>&lt;p&gt;
   Long time no written, I know.... I am quite busy these days at work and in my private
   time working on the web 2.0 startup with my colleagues.
&lt;/p&gt;
&lt;p&gt;
   I received an email from &lt;strong&gt;Kevin Gao&lt;/strong&gt;, which is the leading developer
   of a nice source control software that called SourceAnywhere Hosted of &lt;a href="http://www.dynamsoft.com/" target=_blank&gt;Dynamsoft&lt;/a&gt; in
   order to check out their software tool. I decided to write about this tool, because
   this one is very suitable to me these days while working on my startup project. I
   actually needed a good source control in order to manage my code files properly.
&lt;/p&gt;
&lt;p&gt;
   So, some conclusions regarding this tool, after working with it close to a month.
   Let start from the important thing for small developers like me - this tool is &lt;strong&gt;FREE &lt;/strong&gt;to
   use for up to 3 users, which can be suitable for small to medium projects with low
   number of developers. 
&lt;/p&gt;
&lt;p&gt;
   The second thing that was fine by me is the interface of this software, which is very
   similar to the Microsoft source control (admit it or not - I am a fan of it... ;)),
   this gave me great a familiar navigation ability between the functionality possibilities
   and indeed there are some nice possibilities and abilities, like: users and groups
   roles management and managing your code files (the usual functionality such as rollback,
   commit, check in/out etc.)
&lt;/p&gt;
&lt;p&gt;
   The only disadvantage that I could think about here is a lack of files' state indicator.
   Dislike other source control tools that I worked with (like: &lt;a href="http://msdn2.microsoft.com/en-us/library/3h0544kx(VS.80).aspx" target=_blank&gt;Microsoft
   source safe control&lt;/a&gt; which indicates a file content changes or file state directly
   in the Visual Studio environment or the &lt;strong&gt;&lt;a href="http://subversion.tigris.org/" target=_blank&gt;SubVersion&lt;/a&gt;&lt;/strong&gt; control
   system, which indicates the file's state in in the actual file system folder), this
   tool doesn't indicates it and this is kind of annoying.
&lt;/p&gt;
&lt;p&gt;
   Generally I think this is a great tool to use it in order to manage your code version
   - again for small to&amp;nbsp; medium applications/projects.
&lt;/p&gt;
&lt;p&gt;
   You can read about it and download it free of charge (for up to 3 users of course) &lt;a href="http://www.dynamsoft.com/Products/SAWhosted_Overview.aspx" target=_blank&gt;here&lt;/a&gt;.
   Have fun!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.eranachum.com/aggbug.ashx?id=7d33d50f-e287-4cf0-83d1-696537a681cf" /&gt;</description>
      <category>Code;Management;Security</category>
    </item>
    <item>
      <trackback:ping>http://www.eranachum.com/Trackback.aspx?guid=23d7f48a-2af9-4350-a0d3-25d4f08a3d67</trackback:ping>
      <pingback:server>http://www.eranachum.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.eranachum.com/PermaLink,guid,23d7f48a-2af9-4350-a0d3-25d4f08a3d67.aspx</pingback:target>
      <dc:creator>eranachum@hotmail.com (Eran Nachum)</dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
      Hi fellows, how are you?
   </p>
        <p>
      I read a nice article regarding editing and encrypting/decrypting web.config
      sections. The nicest thing in that feature is the ability to access to the web.config
      content via the actual code behind (and) in run-time. (Could be a lot of reasons
      to access the file from the code itself, and the API is very 'friendly').
   </p>
        <p>
      Click <a href="http://www.c-sharpcorner.com/UploadFile/neo_matrix/EditWebConfig05042007091116AM/EditWebConfig.aspx" target="_blank">here</a> to
      get the directive to this article.
   </p>
        <p>
      Bye bye...
   </p>
        <img width="0" height="0" src="http://www.eranachum.com/aggbug.ashx?id=23d7f48a-2af9-4350-a0d3-25d4f08a3d67" />
      </body>
      <title>Edit and encrypt Web.Config sections using C# 2.0</title>
      <guid>http://www.eranachum.com/PermaLink,guid,23d7f48a-2af9-4350-a0d3-25d4f08a3d67.aspx</guid>
      <link>http://www.eranachum.com/PermaLink,guid,23d7f48a-2af9-4350-a0d3-25d4f08a3d67.aspx</link>
      <pubDate>Thu, 17 May 2007 08:23:55 GMT</pubDate>
      <description>&lt;p&gt;
   Hi fellows, how are you?
&lt;/p&gt;
&lt;p&gt;
   I read&amp;nbsp;a nice article regarding editing and encrypting/decrypting web.config
   sections. The nicest thing in that feature is the ability to access to the web.config
   content via the actual code behind (and) in run-time. (Could be&amp;nbsp;a lot of reasons
   to access the file from the code itself, and the API is very 'friendly').
&lt;/p&gt;
&lt;p&gt;
   Click&amp;nbsp;&lt;a href="http://www.c-sharpcorner.com/UploadFile/neo_matrix/EditWebConfig05042007091116AM/EditWebConfig.aspx" target=_blank&gt;here&lt;/a&gt;&amp;nbsp;to
   get the directive to this article.
&lt;/p&gt;
&lt;p&gt;
   Bye bye...
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.eranachum.com/aggbug.ashx?id=23d7f48a-2af9-4350-a0d3-25d4f08a3d67" /&gt;</description>
      <category>.NET 2005;Code;Security</category>
    </item>
    <item>
      <trackback:ping>http://www.eranachum.com/Trackback.aspx?guid=446d9fe4-da80-474d-93e6-05ef76444644</trackback:ping>
      <pingback:server>http://www.eranachum.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.eranachum.com/PermaLink,guid,446d9fe4-da80-474d-93e6-05ef76444644.aspx</pingback:target>
      <dc:creator>eranachum@hotmail.com (Eran Nachum)</dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
      Hello!
   </p>
        <p>
          <strong>Some intro:<br /></strong>I am starting to migrate a classic asp web application (quite complicated)
      to .NET 2.0 environment and in the begining (of course) I am starting to learn the
      functionality of the existing web app.
   </p>
        <p>
      This morning I came to work and started to rrun the asp web app, but my IIS (5.0)
      seemed to be dead. I couldn't run anything, even the localhost help page to get some
      information.
   </p>
        <p>
      I disabled the "Show friendly HTTP error messages" from the explorer advanced options,
      and | got this messgae: <strong>"The server has encountered an error while loading
      an application during the processing of your request" - </strong>Interesting...
   </p>
        <p>
      After doing some actions in the IIS, I succeeded solving the problem myself, I just
      changed the application protection to Low in the virtual directory folder properties.
   </p>
        <p>
          <strong>Some info:<br /></strong>The Application Protection drop-down determines if this IIS Application is
      to be isolated in its own process, pooled with other apps, or in-process with IIS.
      This feature comes to give us the ability of isolating applications, configuring them
      to run in a process (memory space) that is separate from the Web server and other
      applications. You can configure applications to have one of three levels of application
      protection: Low, Medium, High.
   </p>
        <p>
      Another thing is: The application protection determines how memory resources
      are allocated for ASP pages:
   </p>
        <ul>
          <li>
            <strong>Low (IIS Process):</strong> this level runs ASP pages using the same resources
         as the web service. The advantage of the low level is that you are given the most
         permissions and access. The disadvantage is that if the ASP service fails, the web
         service will be impacted as well. 
      </li>
          <li>
            <strong>Medium (Pooled):</strong> this level allocates a pool of memory resources
         used by all ASP pages. The advantage of the medium level is that you control the amount
         of resources allocated. In addition, if an ASP page causes the ASP service to fail,
         it does not affect the web service. The disadvantage is that if one site causes the
         ASP service to fail, all of the ASP pages will fail. 
      </li>
          <li>
            <strong>High (Isolated):</strong> this level allocates a specific amount of memory
         resources for each ASP application. The advantage to the high level is that if an
         ASP page causes the ASP service to fail, only that specific site will fail and not
         the other sites. The disadvantage is that additional resources are used by each individual
         application pool. 
      </li>
        </ul>
        <p>
      Hope I helped someone...
   </p>
        <img width="0" height="0" src="http://www.eranachum.com/aggbug.ashx?id=446d9fe4-da80-474d-93e6-05ef76444644" />
      </body>
      <title>Is my IIS (5.0) dead?</title>
      <guid>http://www.eranachum.com/PermaLink,guid,446d9fe4-da80-474d-93e6-05ef76444644.aspx</guid>
      <link>http://www.eranachum.com/PermaLink,guid,446d9fe4-da80-474d-93e6-05ef76444644.aspx</link>
      <pubDate>Wed, 11 Apr 2007 08:34:41 GMT</pubDate>
      <description>&lt;p&gt;
   Hello!
&lt;/p&gt;
&lt;p&gt;
   &lt;strong&gt;Some intro:&lt;br&gt;
   &lt;/strong&gt;I am starting to migrate a classic&amp;nbsp;asp web application (quite complicated)
   to .NET 2.0 environment and in the begining (of course) I am starting to learn the
   functionality of the existing web app.
&lt;/p&gt;
&lt;p&gt;
   This morning I came to work and started to rrun the asp web app, but my IIS (5.0)
   seemed to be dead. I couldn't run anything, even the localhost help page to get some
   information.
&lt;/p&gt;
&lt;p&gt;
   I disabled the "Show friendly HTTP error messages" from the explorer advanced options,
   and | got this messgae: &lt;strong&gt;"The server has encountered an error while loading
   an application during the processing of your request" - &lt;/strong&gt;Interesting...
&lt;/p&gt;
&lt;p&gt;
   After doing some actions in the IIS, I succeeded solving the problem myself, I just
   changed the application protection to Low in the virtual directory folder properties.
&lt;/p&gt;
&lt;p&gt;
   &lt;strong&gt;Some info:&lt;br&gt;
   &lt;/strong&gt;The Application Protection drop-down determines if this IIS Application is
   to be isolated in its own process, pooled with other apps, or in-process with IIS.
   This feature comes to give us the ability of isolating applications, configuring them
   to run in a process (memory space) that is separate from the Web server and other
   applications. You can configure applications to have one of three levels of application
   protection: Low, Medium, High.
&lt;/p&gt;
&lt;p&gt;
   Another thing is: The&amp;nbsp;application protection determines how memory resources
   are allocated for ASP pages:
&lt;/p&gt;
&lt;ul&gt;
   &lt;li&gt;
      &lt;strong&gt;Low (IIS Process):&lt;/strong&gt; this level runs ASP pages using the same resources
      as the web service. The advantage of the low level is that you are given the most
      permissions and access. The disadvantage is that if the ASP service fails, the web
      service will be impacted as well. 
   &lt;li&gt;
      &lt;strong&gt;Medium (Pooled):&lt;/strong&gt; this level allocates a pool of memory resources
      used by all ASP pages. The advantage of the medium level is that you control the amount
      of resources allocated. In addition, if an ASP page causes the ASP service to fail,
      it does not affect the web service. The disadvantage is that if one site causes the
      ASP service to fail, all of the ASP pages will fail. 
   &lt;li&gt;
      &lt;strong&gt;High (Isolated):&lt;/strong&gt; this level allocates a specific amount of memory
      resources for each ASP application. The advantage to the high level is that if an
      ASP page causes the ASP service to fail, only that specific site will fail and not
      the other sites. The disadvantage is that additional resources are used by each individual
      application pool. 
   &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
   Hope I helped someone...
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.eranachum.com/aggbug.ashx?id=446d9fe4-da80-474d-93e6-05ef76444644" /&gt;</description>
      <category>Security;System</category>
    </item>
    <item>
      <trackback:ping>http://www.eranachum.com/Trackback.aspx?guid=3bc530eb-3fcf-4c49-8a84-1c79fb265b9b</trackback:ping>
      <pingback:server>http://www.eranachum.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.eranachum.com/PermaLink,guid,3bc530eb-3fcf-4c49-8a84-1c79fb265b9b.aspx</pingback:target>
      <dc:creator>eranachum@hotmail.com (Eran Nachum)</dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
      Hey guys how are you?
   </p>
        <p>
      After long conversation with my work colleague, I thought that I need to sharpen the
      evidences about <strong>Application Domains - </strong>aka <strong>AppDomain.</strong></p>
        <p>
      By .NET environment, the concept of an application domain, or AppDomain known as a
      process. The AppDomain is both a container and a boundary. The .NET runtime uses an
      AppDomain as a container for code and data, just like the operating system uses a
      process as a container for code and data. As the operating system uses a process
      to isolate misbehaving code, the .NET runtime uses an AppDomain to isolate code inside
      of a secure boundary. 
   </p>
        <p>
      An AppDomain belongs to only a single process, but single process can hold multiple
      AppDomains. An AppDomain is relatively cheap to create (compared to a process), and
      has relatively less overhead to maintain than a process. For these reasons, an AppDomain
      is a great solution for the ISP who is hosting hundreds of applications. Each application
      can exist inside an isolated AppDomain, and many of these AppDomains can exist inside
      of a single process – a cost savings.
   </p>
        <p>
      Lets take an example from the <strong>REAL </strong>life:<br />
      Assume that you had created 2 ASP.NET aplpications in the same server, what will happen
      intior the system?
   </p>
        <p>
      Firstable, the ASP.NET process that runs the web application will run both the applications
      (you can find the process name in the task manager as <strong>aspnet_wp.exe</strong> in
      Windows XP or as <strong>w3wp.exe</strong> in Windows 2003. Each application
      will have its own AppDomain including its Cache, Application, and Session objects.<br />
      BUT, the code of the same application runs under the same process!
   </p>
        <p>
          <strong>What about static members or shared classes? </strong>In this case, each ApDomain
      will have its own copy of the static members (fields), but of course, the data and
      code is not shared and will be held safely isolated and inside of a boundary provided
      by the AppDomain.
   </p>
        <p>
          <strong>Load some new assemblies..<br /></strong>Suppose you want to load an updated dll into the application folder or subdirectory,
      the ASP.NET runtime will recognize it and and will start a new AppDomain because it
      cannot insert it to the running AppDomain, the result is that running requests will
      finish its work and after it they will work against the new AppDomain that holds the
      new dll and executing code.
   </p>
        <p>
          <strong>Last word...<br /></strong>I think that one of the good adventages of the AppDomain is that you can
      allocate the wanted memory for your application (under its AppDomain) as much
      as you want (bounded by the process capability of course) and if there is a runtime
      crash, the rest of the applciations that runs over the current process will not crash.
   </p>
        <p>
      I will glad to hear some comments and additions... :)
   </p>
        <img width="0" height="0" src="http://www.eranachum.com/aggbug.ashx?id=3bc530eb-3fcf-4c49-8a84-1c79fb265b9b" />
      </body>
      <title>Lets talk about Application Domains</title>
      <guid>http://www.eranachum.com/PermaLink,guid,3bc530eb-3fcf-4c49-8a84-1c79fb265b9b.aspx</guid>
      <link>http://www.eranachum.com/PermaLink,guid,3bc530eb-3fcf-4c49-8a84-1c79fb265b9b.aspx</link>
      <pubDate>Thu, 23 Nov 2006 13:03:00 GMT</pubDate>
      <description>&lt;p&gt;
   Hey guys how are you?
&lt;/p&gt;
&lt;p&gt;
   After long conversation with my work colleague, I thought that I need to sharpen the
   evidences about &lt;strong&gt;Application Domains - &lt;/strong&gt;aka &lt;strong&gt;AppDomain.&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
   By .NET environment, the concept of an application domain, or AppDomain known as a
   process. The AppDomain is both a container and a boundary. The .NET runtime uses an
   AppDomain as a container for code and data, just like the operating system uses a
   process as a container for code and data.&amp;nbsp;As the operating system uses a process
   to isolate misbehaving code, the .NET runtime uses an AppDomain to isolate code inside
   of a secure boundary. 
&lt;/p&gt;
&lt;p&gt;
   An AppDomain belongs to only a single process, but single process can hold multiple
   AppDomains. An AppDomain is relatively cheap to create (compared to a process), and
   has relatively less overhead to maintain than a process. For these reasons, an AppDomain
   is a great solution for the ISP who is hosting hundreds of applications. Each application
   can exist inside an isolated AppDomain, and many of these AppDomains can exist inside
   of a single process – a cost savings.
&lt;/p&gt;
&lt;p&gt;
   Lets take an example from the &lt;strong&gt;REAL &lt;/strong&gt;life:&lt;br&gt;
   Assume that you had created 2 ASP.NET aplpications in the same server, what will happen
   intior the system?
&lt;/p&gt;
&lt;p&gt;
   Firstable, the ASP.NET process that runs the web application will run both the applications
   (you can find the process name in the task manager as &lt;strong&gt;aspnet_wp.exe&lt;/strong&gt; in
   Windows XP or as &lt;strong&gt;w3wp.exe&lt;/strong&gt;&amp;nbsp;in Windows 2003. Each application
   will have its own AppDomain including its Cache, Application, and Session objects.&lt;br&gt;
   BUT, the code of the same application runs under the same process!
&lt;/p&gt;
&lt;p&gt;
   &lt;strong&gt;What about static members or shared classes? &lt;/strong&gt;In this case, each ApDomain
   will have its own copy of the static members (fields), but of course, the data and
   code is not shared and will be held safely isolated and inside of a boundary provided
   by the AppDomain.
&lt;/p&gt;
&lt;p&gt;
   &lt;strong&gt;Load some new&amp;nbsp;assemblies..&lt;br&gt;
   &lt;/strong&gt;Suppose you want to load an updated dll into the application folder or subdirectory,
   the ASP.NET runtime will recognize it and and will start a new AppDomain because it
   cannot insert it to the running AppDomain, the result is that running requests will
   finish its work and after it they will work against the new AppDomain that holds the
   new dll and executing code.
&lt;/p&gt;
&lt;p&gt;
   &lt;strong&gt;Last word...&lt;br&gt;
   &lt;/strong&gt;I think that one of the good adventages of the AppDomain is that you can
   allocate the wanted memory for your application (under its AppDomain)&amp;nbsp;as much
   as you want (bounded by the process capability of course) and if there is a runtime
   crash, the rest of the applciations that runs over the current process will not crash.
&lt;/p&gt;
&lt;p&gt;
   I will glad to hear some comments and additions... :)
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.eranachum.com/aggbug.ashx?id=3bc530eb-3fcf-4c49-8a84-1c79fb265b9b" /&gt;</description>
      <category>.NET 2005;Security;System</category>
    </item>
    <item>
      <trackback:ping>http://www.eranachum.com/Trackback.aspx?guid=2dbb3709-11c5-4a6e-9093-fadf8eb18e73</trackback:ping>
      <pingback:server>http://www.eranachum.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.eranachum.com/PermaLink,guid,2dbb3709-11c5-4a6e-9093-fadf8eb18e73.aspx</pingback:target>
      <dc:creator>eranachum@hotmail.com (Eran Nachum)</dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
      Hello and good week to all!
   </p>
        <p>
      These days I am starting to publish here (in my <a href="http://www.eranachum.com/" target="_blank">blog</a> ofcourse)
      a series of articles that discusses with Web Serivces and the most important issue
      - Security over Web Services (using Microsoft technology ofcourse), because it is
      quite simple to write a web service that receives/retrieves data and 'do you thing...',
      but the complexity comes when you want to secure this data that runs over non-secured
      protocols or web-lines.
   </p>
        <p>
      This article assumes that you are familier with web services, its porpuse and its
      implementation and assimilations, if not, you should read some basic tutorials before
      you start to read this article. (You can fine general example <a href="http://samples.gotdotnet.com/quickstart/aspplus/doc/writingservices.aspx" target="_blank">here</a>).
   </p>
        <p>
          <strong>
            <u>Introduction<br /></u>
          </strong>WS-SecurityProtocol defines all web services expansion security topics.
      Its goal is to let you build and use SOAP messages exchange in secured way. This term
      is quite flexble and it designed in a specific way in order to constitute the base
      of building a secured Web Service by the different security models like: SSL,
      Kerberos, PKI.<br />
      WS-SecurityProtocol supplies a full support for large number of security tokens, trusted
      domains, signature formats and encryption technologies.
   </p>
        <p>
      This component supplies 3 basic mechanisms: <strong>Message Confindentiality, Message
      Integrity, Security Token Propagation.</strong> These mechanisms, each one by it own,
      doesn't supplies perfect security solution, therefore in actual fact, WS-SecurityProtocol
      builds a block that uses a combination of all there mechanisms and different enhancements
      to supply a perfect sucurity solution
   </p>
        <p>
          <strong>
            <u>Main Facts<br /></u>
          </strong>Before I start explaining and showing the protocol's structure, I want
      to stand on the basic definitions and terms this protocol is uses:
   </p>
        <ul>
          <li>
            <strong>Claim</strong> - the client's claim (like: name, identity, key, group, rights
         and more...) 
      </li>
          <li>
            <strong>Security Token</strong> - represent a set of tokens. 
      </li>
          <li>
            <strong>Signed Security Token</strong> - this is a claimed and encrypted by a specific
         authority (like: Kerberos ticket or X.509 certificate) security token. 
      </li>
          <li>
            <strong>Proof-of-possession</strong> - information that used by a specific "proof
         process" in purpose to describe the sender data. 
      </li>
          <li>
            <strong>Integrity</strong> - a process that comes to note that the sent data hasn't
         changed while sending the message. 
      </li>
          <li>
            <strong>Confidentiality </strong>- a process that comes to ensure that the data is
         protected and just specific authorized 'players' are allowed to watch it. 
      </li>
          <li>
            <strong>Digest</strong> - an encrypted sum of the data sent stream. 
      </li>
          <li>
            <strong>Signature </strong>- this is an encrypted communication between the Proof-of-possession
         and the digest. This action creates a symetric key and public signatures. 
      </li>
          <li>
            <strong>Attachment</strong> - this is the physical data that is transfered using the
         SOAP messages, <u>but</u> is not a part of the SOAP envelop.</li>
        </ul>
        <p>
      We want to ensure that the SOAP message is encrypted properly to avoid dangers, like:
   </p>
        <ol>
          <li>
         The message could be readen and be changed by malicious user. 
      </li>
          <li>
         Malicious user can send fake message through the Web Service and by that to get secret
         information.</li>
        </ol>
        <p>
          <strong>Message Security Model</strong>
        </p>
        <p>
      The WS-SecurityProtocol works under the <strong>Message Security Model</strong>, that
      comes to prevent such cases like mentioned above. Its behavior is:
   </p>
        <p>
      The Security Token declares on Claims and Signatures, this mechanism supplies a proof
      to the knowledge of the sender (in simple words, the data that the sender holds).
      In addition, the Signature can bind itself with the Claims in the Security Token (in
      assumption the token is secured).
   </p>
        <p>
      Claim can be supported (or not) by "secured authority", which is a set of
      claims, which encrypted or digitally signed by this authority is usually represented
      by Signed Security Tokens. An example to Signed Security Token set is <strong>X.509</strong><strong>Certificate </strong>-
      which by this set of claims, the binding is executed between the client identity and
      the the public key.<br />
      Claim that is not supported by any "secured authority", can be secured only when
      the connection (binding) between the sender and the receiver is secured (secured line,
      like SSL etc...), for an example, they can agree on a specific message name that is
      accepted by both of them and by that only they will know that the message is meant
      for them (because they are both will look forward to get the same name).
   </p>
        <p>
      Another type of non-secured claim (which is not supported by any "secured authority")
      called <strong>proof-of-possesion</strong>. As I descibed earlier, this term confirms
      that the user has "pieces" of knowledge that diagnosed by the other 'players' which
      related to it. For an example, lets take a look of username/password security token,
      the proof-of-possession here, combines another security token in order to confirm
      the sender's claim. I need to note here, that Digital integrity (see above if you
      already forgot) for a message can be used as a proof-of-possession, but in theis case
      it will not considered as a security token.
   </p>
        <p>
          <strong>Message Protection</strong>
        </p>
        <p>
      Another model that comes to prevent such cases as mentioned above (remember...?).<br />
      This model claims that all the messages that are being sent, supposed to be encrypted
      in order to not be negatively affected by hostile factors. The Integrity based
      message is supplied by leverage of an XML signature with security tokens, in order
      to notice that the messages has been sent with no data changes of bad influences.
      This mechanism supports many signatures and players.
   </p>
        <p>
      A confidentiality (see above for a definition), based message, uses XML encryption
      with secutity tokens to ensure that the message's parts will be confidential.
   </p>
        <p>
      In order to supply the the maximum security to the SOAP message, that we'll
      want to send, there is a need to build the XML file that includes all the filters
      and headers definitions.<br />
      The structure of the XML file includes the &lt;Security&gt; tag, which symbolizes
      the security definitions. Under this tag it is possible to define all the information
      about the message security issue.
   </p>
        <p>
      An XML file cannot hold more that one security tag, this in purpose to allow that
      each tag (security XML) will taget to other destination. This tag and all its data
      under, represents the signature steps and the encryption type that the sender used
      with to send the message.
   </p>
        <p>
      A typical WS-SecurityProtocol example:
   </p>
        <p align="center">
          <img src="http://www.eranachum.com/content/binary/WS-SecurityProtocol.jpg" border="0" />
        </p>
        <p align="left">
      Line 001 and 002, describes the SOAP envelope. Line 003 opens the headers definitions
      that describes the message. Line 004 to 008, describes the sending message type, the
      source and destination. 
   </p>
        <p align="left">
      Line 009, open the Security's filters definitions. This label defines the security
      definitions that the receiver need to be up to (in order to watch the message ofcourse).
      This header label is closed in line 029.
   </p>
        <p align="left">
      Lines 010 to 012, describes the security token that message uses, here the usage is
      username token. (Here the assumption is that the password is well known by the service,
      and by that, only username is being sent).
   </p>
        <p align="left">
      Lines 013 to 028 defines the digital signature. By this example, the signature is
      based on the key that generated from the sender password. Lines 014 to 021,
      explains the digital signature. Line 015 defines how to normilize the sent information.
   </p>
        <p align="left">
      Lines 017 to 020, chooses the elements we want to signature. In this example (by line
      017), we can see that the body is digitally signed (&lt;s:Body&gt; label, which you
      can see in line 031).
   </p>
        <p align="left">
      Line 022, holds tha signature value that derivated from the encrypted information.
      Lines 023 to 027, holds an information about the security token location, which combined
      with the signature. In more explicit, lines 024 - 025, defines that this
      token is located in a specific URL address.
   </p>
        <p align="center">
          <img src="http://www.eranachum.com/content/binary/WS-SecurityToken02.jpg" border="0" />
        </p>
        <p align="left">
      Line 031 to 033 holds the message body.
   </p>
        <p align="left">
      That it for now. More tutorials at:
   </p>
        <ul>
          <li>
            <div align="left">
              <a href="http://www-128.ibm.com/developerworks/webservices/library/ws-secure/">http://www-128.ibm.com/developerworks/webservices/library/ws-secure/</a>
            </div>
          </li>
          <li>
            <div align="left">
              <a href="http://msdn.microsoft.com/library/en-us/dnglobspec/html/ws-securitypolicy.pdf">http://msdn.microsoft.com/library/en-us/dnglobspec/html/ws-securitypolicy.pdf</a>
            </div>
          </li>
        </ul>
        <p align="left">
      Comments will be appriciated...
   </p>
        <img width="0" height="0" src="http://www.eranachum.com/aggbug.ashx?id=2dbb3709-11c5-4a6e-9093-fadf8eb18e73" />
      </body>
      <title>Web Service Security Policy (WS-SecurityPolicy)</title>
      <guid>http://www.eranachum.com/PermaLink,guid,2dbb3709-11c5-4a6e-9093-fadf8eb18e73.aspx</guid>
      <link>http://www.eranachum.com/PermaLink,guid,2dbb3709-11c5-4a6e-9093-fadf8eb18e73.aspx</link>
      <pubDate>Sun, 23 Jul 2006 05:44:39 GMT</pubDate>
      <description>&lt;p&gt;
   Hello and good week to all!
&lt;/p&gt;
&lt;p&gt;
   These days I am starting to publish here (in my &lt;a href="http://www.eranachum.com/" target=_blank&gt;blog&lt;/a&gt; ofcourse)
   a series of articles that discusses with Web Serivces and the most important issue
   - Security over Web Services (using Microsoft technology ofcourse), because it is
   quite simple to write a web service that receives/retrieves data and 'do you thing...',
   but the complexity comes when you want to secure this data that runs over non-secured
   protocols or web-lines.
&lt;/p&gt;
&lt;p&gt;
   This article assumes that you are familier with web services, its porpuse and its
   implementation and assimilations, if not, you should read some basic tutorials before
   you start to read this article. (You can fine general example &lt;a href="http://samples.gotdotnet.com/quickstart/aspplus/doc/writingservices.aspx" target=_blank&gt;here&lt;/a&gt;).
&lt;/p&gt;
&lt;p&gt;
   &lt;strong&gt;&lt;u&gt;Introduction&lt;br&gt;
   &lt;/u&gt;&lt;/strong&gt;WS-SecurityProtocol defines all web services expansion security topics.
   Its goal is to let you build and use SOAP messages exchange in secured way. This term
   is quite flexble and it designed in a specific way in order to constitute&amp;nbsp;the&amp;nbsp;base
   of building a secured Web Service by the different security&amp;nbsp;models like: SSL,
   Kerberos, PKI.&lt;br&gt;
   WS-SecurityProtocol supplies a full support for large number of security tokens, trusted
   domains, signature formats and encryption technologies.
&lt;/p&gt;
&lt;p&gt;
   This component supplies 3 basic mechanisms: &lt;strong&gt;Message Confindentiality, Message
   Integrity, Security Token Propagation.&lt;/strong&gt; These mechanisms, each one by it own,
   doesn't supplies perfect security solution, therefore in actual fact, WS-SecurityProtocol
   builds a block that uses a combination of all there mechanisms and different enhancements
   to supply a perfect sucurity solution
&lt;/p&gt;
&lt;p&gt;
   &lt;strong&gt;&lt;u&gt;Main Facts&lt;br&gt;
   &lt;/u&gt;&lt;/strong&gt;Before I start explaining and showing the protocol's structure, I want
   to stand on the basic definitions and terms this protocol is uses:
&lt;/p&gt;
&lt;ul&gt;
   &lt;li&gt;
      &lt;strong&gt;Claim&lt;/strong&gt; - the client's claim (like: name, identity, key, group, rights
      and more...) 
   &lt;li&gt;
      &lt;strong&gt;Security Token&lt;/strong&gt; - represent a set of tokens. 
   &lt;li&gt;
      &lt;strong&gt;Signed Security Token&lt;/strong&gt; - this is a claimed and encrypted by a specific
      authority (like: Kerberos ticket or X.509 certificate) security token. 
   &lt;li&gt;
      &lt;strong&gt;Proof-of-possession&lt;/strong&gt; - information that used by a specific "proof
      process" in purpose to describe the sender data. 
   &lt;li&gt;
      &lt;strong&gt;Integrity&lt;/strong&gt; - a process that comes to note that the sent data hasn't
      changed while sending the message. 
   &lt;li&gt;
      &lt;strong&gt;Confidentiality &lt;/strong&gt;- a process that comes to ensure that the data is
      protected and just specific authorized 'players' are allowed to watch it. 
   &lt;li&gt;
      &lt;strong&gt;Digest&lt;/strong&gt; - an encrypted sum of the data sent stream. 
   &lt;li&gt;
      &lt;strong&gt;Signature &lt;/strong&gt;- this is an encrypted communication between the Proof-of-possession
      and the digest. This action creates a symetric key and public signatures. 
   &lt;li&gt;
      &lt;strong&gt;Attachment&lt;/strong&gt; - this is the physical data that is transfered using the
      SOAP messages, &lt;u&gt;but&lt;/u&gt; is not a part of the SOAP envelop.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
   We want to ensure that the SOAP message is encrypted properly to avoid dangers, like:
&lt;/p&gt;
&lt;ol&gt;
   &lt;li&gt;
      The message could be readen and be changed by malicious user. 
   &lt;li&gt;
      Malicious user can send fake message through the Web Service and by that to get secret
      information.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
   &lt;strong&gt;Message Security Model&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
   The WS-SecurityProtocol works under the &lt;strong&gt;Message Security Model&lt;/strong&gt;, that
   comes to prevent such cases like mentioned above. Its behavior is:
&lt;/p&gt;
&lt;p&gt;
   The Security Token declares on Claims and Signatures, this mechanism supplies a proof
   to the knowledge of the sender (in simple words, the data that the sender holds).
   In addition, the Signature can bind itself with the Claims in the Security Token (in
   assumption the token is secured).
&lt;/p&gt;
&lt;p&gt;
   Claim can be supported (or not) by "secured authority",&amp;nbsp;which is&amp;nbsp;a set of
   claims, which encrypted or digitally signed by this authority is usually represented
   by Signed Security Tokens. An example to Signed Security Token set is &lt;strong&gt;X.509&lt;/strong&gt; &lt;strong&gt;Certificate &lt;/strong&gt;-
   which by this set of claims, the binding is executed between the client identity and
   the the public key.&lt;br&gt;
   Claim that is not supported by any&amp;nbsp;"secured authority", can be secured only when
   the connection (binding) between the sender and the receiver is secured (secured line,
   like SSL etc...), for an example, they can agree on a specific message name that is
   accepted by both of them and by that only they will know that the message is meant
   for them (because they are both will look forward to get the same name).
&lt;/p&gt;
&lt;p&gt;
   Another type of non-secured claim (which is not supported by any "secured authority")
   called &lt;strong&gt;proof-of-possesion&lt;/strong&gt;. As I descibed earlier, this term confirms
   that the user has "pieces" of knowledge that diagnosed by the other 'players' which
   related to it. For an example, lets take a look of username/password security token,
   the proof-of-possession here, combines another security token in order to confirm
   the sender's claim. I need to note here, that Digital integrity (see above if you
   already forgot) for a message can be used as a proof-of-possession, but in theis case
   it will not considered as a security token.
&lt;/p&gt;
&lt;p&gt;
   &lt;strong&gt;Message Protection&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
   Another model that comes to prevent such cases as mentioned above (remember...?).&lt;br&gt;
   This&amp;nbsp;model claims that all the messages that are being sent, supposed to be encrypted
   in order to not be negatively affected&amp;nbsp;by hostile factors. The Integrity based
   message is supplied by leverage of an XML signature with security tokens, in order
   to notice that the messages has been sent with no data changes of bad influences.
   This mechanism supports many signatures and players.
&lt;/p&gt;
&lt;p&gt;
   A confidentiality (see above for a definition),&amp;nbsp;based message, uses XML encryption
   with secutity tokens to ensure that the message's parts will be confidential.
&lt;/p&gt;
&lt;p&gt;
   In order to supply the the maximum security&amp;nbsp;to the SOAP&amp;nbsp;message, that we'll
   want to send, there is a need to build the XML file that includes all the filters
   and headers definitions.&lt;br&gt;
   The structure of the XML file includes the &amp;lt;Security&amp;gt; tag, which&amp;nbsp;symbolizes
   the security definitions. Under this tag it is possible to define all the information
   about the message security issue.
&lt;/p&gt;
&lt;p&gt;
   An XML file cannot hold more that one security tag, this in purpose to allow that
   each tag (security XML) will taget to other destination. This tag and all its data
   under, represents the signature steps and the encryption type that the sender used
   with to send the message.
&lt;/p&gt;
&lt;p&gt;
   A typical WS-SecurityProtocol example:
&lt;/p&gt;
&lt;p align=center&gt;
   &lt;img src="http://www.eranachum.com/content/binary/WS-SecurityProtocol.jpg" border=0&gt;
&lt;/p&gt;
&lt;p align=left&gt;
   Line 001 and 002, describes the SOAP envelope. Line 003 opens the headers definitions
   that describes the message. Line 004 to 008, describes the sending message type, the
   source and destination. 
&lt;/p&gt;
&lt;p align=left&gt;
   Line 009, open the Security's filters definitions. This label defines the security
   definitions that the receiver need to be up to (in order to watch the message ofcourse).
   This header label is closed in line 029.
&lt;/p&gt;
&lt;p align=left&gt;
   Lines 010 to 012, describes the security token that message uses, here the usage is
   username token. (Here the assumption is that the password is well known by the service,
   and by that, only username is being sent).
&lt;/p&gt;
&lt;p align=left&gt;
   Lines 013 to 028 defines the digital signature. By this example, the signature is
   based&amp;nbsp;on&amp;nbsp;the key that generated from the sender password. Lines 014 to 021,
   explains the digital signature. Line 015 defines how to normilize the sent information.
&lt;/p&gt;
&lt;p align=left&gt;
   Lines 017 to 020, chooses the elements we want to signature. In this example (by line
   017), we can see that the body is digitally signed (&amp;lt;s:Body&amp;gt; label, which you
   can see in line 031).
&lt;/p&gt;
&lt;p align=left&gt;
   Line 022, holds tha signature value that derivated from the encrypted information.
   Lines 023 to 027, holds an information about the security token location, which combined
   with the signature. In&amp;nbsp;more explicit, lines 024 - 025, defines&amp;nbsp;that this
   token is located in a specific URL address.
&lt;/p&gt;
&lt;p align=center&gt;
   &lt;img src="http://www.eranachum.com/content/binary/WS-SecurityToken02.jpg" border=0&gt;
&lt;/p&gt;
&lt;p align=left&gt;
   Line 031 to 033 holds the message body.
&lt;/p&gt;
&lt;p align=left&gt;
   That it for now. More tutorials at:
&lt;/p&gt;
&lt;ul&gt;
   &lt;li&gt;
      &lt;div align=left&gt;&lt;a href="http://www-128.ibm.com/developerworks/webservices/library/ws-secure/"&gt;http://www-128.ibm.com/developerworks/webservices/library/ws-secure/&lt;/a&gt;
      &lt;/div&gt;
   &lt;li&gt;
      &lt;div align=left&gt;&lt;a href="http://msdn.microsoft.com/library/en-us/dnglobspec/html/ws-securitypolicy.pdf"&gt;http://msdn.microsoft.com/library/en-us/dnglobspec/html/ws-securitypolicy.pdf&lt;/a&gt;
      &lt;/div&gt;
   &lt;/li&gt;
&lt;/ul&gt;
&lt;p align=left&gt;
   Comments will be appriciated...
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.eranachum.com/aggbug.ashx?id=2dbb3709-11c5-4a6e-9093-fadf8eb18e73" /&gt;</description>
      <category>Security;Web Services</category>
    </item>
    <item>
      <trackback:ping>http://www.eranachum.com/Trackback.aspx?guid=49045260-a0da-4375-9106-dcb77b035a4c</trackback:ping>
      <pingback:server>http://www.eranachum.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.eranachum.com/PermaLink,guid,49045260-a0da-4375-9106-dcb77b035a4c.aspx</pingback:target>
      <dc:creator>eranachum@hotmail.com (Eran Nachum)</dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
      Many articles and approaches claims that it doesn't matter what is the application
      security level, or what is the security level of the environment the application
      is stored in (like working under SSL using https protocol etc...), you should always
      save all passwords and secret data <strong>encrypted</strong>. That because there
      is always a chance, even little one, that someone could steal your confidential data.
   </p>
        <p>
      There are many hashing functions and alogorithms, several are MD5, SHA1 and more... <u>but</u>,
      these algorithms are too old (compare to our modern days), there generates 'only'
      a 128 bits value, so the space of posible resulting values is 2<sup>128</sup> in size,
      which by creating a crack script, like the <a href="http://passcracking.com/" target="_blank">passcracking</a> project
      the hash could be broken.
   </p>
        <p>
      Because of these limitaions and cracking possibilities it is not recommended to use
      this type of hasing functions. Better solution you wiil see later... (hold on :) ).
   </p>
        <p>
          <u>
            <strong>One way Hash Functions</strong>
          </u>
        </p>
        <p dir="ltr">
      The following definitions are taken from the Bruce Schneier's Book: Applied
      Cryptography Second Edition:
   </p>
        <blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
          <p>
      A one-way hash function, <i>H</i>(<i>M</i>), operates on an arbitrary-length pre-image
      message, <i>M</i>. It returns a fixed-length hash value, <i>h</i>.
   </p>
          <dl>
            <dd>
              <i>h</i> = H(<i>M</i>), where <i>h</i> is of length <i>m</i></dd>
          </dl>
          <p>
      Many functions can take an arbitrary-length input and return an output of fixed length,
      but one-way hash functions have additional characteristics that make them one-way
      [1065]: 
   </p>
        </blockquote>
        <dl>
          <dl>
            <dd>
            Given <i>M</i>, it is easy to compute <i>h</i>. 
            <dd>
               Given <i>h</i>, it is hard to compute <i>M</i> such that <i>H</i>(<i>M</i>)= <i>h</i>. 
               <dd>
                  Given <i>M</i>, it is hard to find another message, M’, such that <i>H</i>(<i>M</i>) <i>=
                  H</i>(<i>M’</i>). 
               </dd></dd></dd>
          </dl>
        </dl>
        <p dir="ltr">
      In some applications, one-wayness is insufficient; we need an additional requirement
      called <b>collision-resistance</b>.
   </p>
        <blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
          <p>
      It is hard to find two random messages, <i>M</i> and <i>M’</i>, such that <i>H</i>(<i>M</i>)
      = <i>H</i>(<i>M’</i>).
   </p>
        </blockquote>
        <p>
      Now, by getting the main idea of the basic hashing algorithm by the Bruce Schneier's
      Book definitions, I want to show you better alternatives that comes to replace and
      enrich the old ones.
   </p>
        <p>
          <a href="http://en.wikipedia.org/wiki/WHIRLPOOL" target="_blank">WHIRPOOL</a> generates
      a 512 bits output, <a href="http://en.wikipedia.org/wiki/RIPEMD-160">RIPEMD</a>, uses
      160, 128 or 320 bits output, but I want to focus in the S<a href="http://en.wikipedia.org/wiki/SHA-2">HA-2</a>, function
      that generates 256, 512 bits ouputs, because there is available API in Microsoft.NET
      framework.
   </p>
        <p>
      The main classes that implements this cryptografic algorithms are:
   </p>
        <ul>
          <li>
            <font size="2">System.Security.Cryptography.</font>
            <font color="#008080" size="2">SHA256Managed</font>
          </li>
          <li>
            <font color="#008080">
              <font color="#003300">System.Security.Cryptography.</font>
              <font color="#008080" size="2">SHA384Managed</font>
            </font>
          </li>
          <li>
            <font size="2">
              <p>
            System.Security.Cryptography.
         </p>
            </font>
            <font color="#008080" size="2">SHA512Managed</font>
          </li>
        </ul>
        <p>
          <font color="#008080">
            <font size="2">
              <font color="#000000">Now to the implementations.
      The following code below shows you an example how to use this function in porpuse
      to encrypt a password or just confidential data that you want to store hashed:</font>
            </font>
          </font>
        </p>
        <p>
          <font color="#008080">
            <font size="2">
              <font color="#000000">
                <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
                  <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
                    <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">byte</span>[]
      data, encryptedBytes;<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">string</span> hashedPassword <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">string</span>.Empty;<br /><br />
      data <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> Encoding.Default.GetBytes(plainPassword);<br />
      System.Security.Cryptography.SHA256 sha2 <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span> System.Security.Cryptography.SHA256Managed();<br />
      encryptedBytes <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> sha2.TransformFinalBlock(data,
      0, data.Length);<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">foreach</span> (<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">byte</span> b <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">in</span> sha2.Hash)<br />
         hashedPassword += Convert.ToString(b, 16).ToUpper().PadLeft(2, '0');<br /><br />
      sha2.Clear();<br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">//
      hashedPassword holds the hashed string</span></span>
                </span>
              </font>
            </font>
          </font>
        </p>
        <p>
          <font face="Verdana" size="2">This example above encript the plain pasword using SHA-2
      algorithm.</font>
        </p>
        <p>
          <font face="Verdana" size="2">The following example uses a <strong>salt </strong>which
      comes to help reduce the risk of dictionary attacks, the code appends random bytes
      (so-called "salt") to the original plain text before generating hashes. Please keep
      in mind that salt can only help against prebuilt dictionaries. If an intruder gets
      access to your system and uses a brute force attack, salt will not provide much value.</font>
        </p>
        <font face="Courier New" size="2">
          <p>
            <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
              <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">string</span> hashedPassword <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">string</span>.Empty;<br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">//generate
      a random salt value by using the following code</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">byte</span>[]
      salt <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">byte</span>[32];<br />
      System.Security.Cryptography.RNGCryptoServiceProvider.Create().GetBytes(salt);<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">byte</span>[]
      salt <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> Encoding.Default.GetBytes(userName);<br /><br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">//Convert
      the plain string password into bytes</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">byte</span>[]
      plainPasswordBytes <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> System.Text.UnicodeEncoding.Unicode.GetBytes(plainPassword);<br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">//
      Append salt to password before hashing</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">byte</span>[]
      combinedBytes <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">byte</span>[plainPasswordBytes.Length <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">+</span> salt.Length];<br />
      System.Buffer.BlockCopy(plainPasswordBytes, 0, combinedBytes, 0, plainPasswordBytes.Length);<br />
      System.Buffer.BlockCopy(salt, 0, combinedBytes, plainPasswordBytes.Length, salt.Length);<br /><br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">//Create
      hash for the password + salt</span><br />
      System.Security.Cryptography.HashAlgorithm hashAlgo <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span> System.Security.Cryptography.SHA256Managed();<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">byte</span>[]
      hash <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> hashAlgo.ComputeHash(combinedBytes);<br /><br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">//Append
      the salt to the hash </span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">byte</span>[]
      hashPlusSalt <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">byte</span>[hash.Length <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">+</span> salt.Length];<br />
      System.Buffer.BlockCopy(hash, 0, hashPlusSalt, 0, hash.Length);<br />
      System.Buffer.BlockCopy(salt, 0, hashPlusSalt, hash.Length, salt.Length);<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">foreach</span> (<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">byte</span> b <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">in</span> hashPlusSalt)<br />
         hashedPassword += Convert.ToString(b, 16).ToUpper().PadLeft(2, '0');<br /><br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">//
      hashedPassword holds the hashed string</span></span>
          </p>
        </font>
        <p>
          <font face="Verdana" size="2">That's it, now use it properly and try to avoid as much
      as you can from brut attacking...</font>
          <font color="#008080">
            <font size="2">
            </font>
          </font>
        </p>
        <img width="0" height="0" src="http://www.eranachum.com/aggbug.ashx?id=49045260-a0da-4375-9106-dcb77b035a4c" />
      </body>
      <title>One way Hash Functions - My favorite is SHA-2</title>
      <guid>http://www.eranachum.com/PermaLink,guid,49045260-a0da-4375-9106-dcb77b035a4c.aspx</guid>
      <link>http://www.eranachum.com/PermaLink,guid,49045260-a0da-4375-9106-dcb77b035a4c.aspx</link>
      <pubDate>Tue, 18 Jul 2006 07:23:57 GMT</pubDate>
      <description>&lt;p&gt;
   Many articles and approaches claims that it doesn't matter what is&amp;nbsp;the application
   security level, or what is the security level&amp;nbsp;of the environment&amp;nbsp;the application
   is stored in (like working under SSL using https protocol etc...), you should always
   save all passwords and secret data &lt;strong&gt;encrypted&lt;/strong&gt;. That because there
   is always a chance, even little one, that someone could steal your confidential data.
&lt;/p&gt;
&lt;p&gt;
   There are many hashing functions and alogorithms, several are MD5, SHA1 and more... &lt;u&gt;but&lt;/u&gt;,
   these algorithms are too old (compare to our modern&amp;nbsp;days), there generates 'only'
   a 128 bits value, so the space of posible resulting values is 2&lt;sup&gt;128&lt;/sup&gt; in size,
   which by creating a crack script, like the &lt;a href="http://passcracking.com/" target=_blank&gt;passcracking&lt;/a&gt; project
   the hash could be broken.
&lt;/p&gt;
&lt;p&gt;
   Because of these limitaions and cracking possibilities it is not recommended to use
   this type of hasing functions. Better solution you wiil see later... (hold on :) ).
&lt;/p&gt;
&lt;p&gt;
   &lt;u&gt;&lt;strong&gt;One way Hash Functions&lt;/strong&gt;&lt;/u&gt;
&lt;/p&gt;
&lt;p dir=ltr&gt;
   The following&amp;nbsp;definitions&amp;nbsp;are taken from the Bruce Schneier's Book: Applied
   Cryptography Second Edition:
&lt;/p&gt;
&lt;blockquote dir=ltr style="MARGIN-RIGHT: 0px"&gt; 
&lt;p&gt;
   A one-way hash function, &lt;i&gt;H&lt;/i&gt;(&lt;i&gt;M&lt;/i&gt;), operates on an arbitrary-length pre-image
   message, &lt;i&gt;M&lt;/i&gt;. It returns a fixed-length hash value, &lt;i&gt;h&lt;/i&gt;.
&lt;/p&gt;
&lt;dl&gt;
   &lt;dd&gt;
      &lt;i&gt;h&lt;/i&gt; = H(&lt;i&gt;M&lt;/i&gt;), where &lt;i&gt;h&lt;/i&gt; is of length &lt;i&gt;m&lt;/i&gt; 
   &lt;/dd&gt;
&lt;/dl&gt;
&lt;p&gt;
   Many functions can take an arbitrary-length input and return an output of fixed length,
   but one-way hash functions have additional characteristics that make them one-way
   [1065]: 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;dl&gt;
   &lt;dl&gt;
      &lt;dd&gt;
         Given &lt;i&gt;M&lt;/i&gt;, it is easy to compute &lt;i&gt;h&lt;/i&gt;. 
         &lt;dd&gt;
            Given &lt;i&gt;h&lt;/i&gt;, it is hard to compute &lt;i&gt;M&lt;/i&gt; such that &lt;i&gt;H&lt;/i&gt;(&lt;i&gt;M&lt;/i&gt;)= &lt;i&gt;h&lt;/i&gt;. 
            &lt;dd&gt;
               Given &lt;i&gt;M&lt;/i&gt;, it is hard to find another message, M’, such that &lt;i&gt;H&lt;/i&gt;(&lt;i&gt;M&lt;/i&gt;) &lt;i&gt;=
               H&lt;/i&gt;(&lt;i&gt;M’&lt;/i&gt;). 
            &lt;/dd&gt;
   &lt;/dl&gt;
&lt;/dl&gt;
&lt;p dir=ltr&gt;
   In some applications, one-wayness is insufficient; we need an additional requirement
   called &lt;b&gt;collision-resistance&lt;/b&gt;.
&lt;/p&gt;
&lt;blockquote dir=ltr style="MARGIN-RIGHT: 0px"&gt; 
&lt;p&gt;
   It is hard to find two random messages, &lt;i&gt;M&lt;/i&gt; and &lt;i&gt;M’&lt;/i&gt;, such that &lt;i&gt;H&lt;/i&gt;(&lt;i&gt;M&lt;/i&gt;)
   = &lt;i&gt;H&lt;/i&gt;(&lt;i&gt;M’&lt;/i&gt;).
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
   Now, by getting the main idea of the basic hashing algorithm by the Bruce Schneier's
   Book definitions, I want to show you better alternatives that comes to replace and
   enrich the old ones.
&lt;/p&gt;
&lt;p&gt;
   &lt;a href="http://en.wikipedia.org/wiki/WHIRLPOOL" target=_blank&gt;WHIRPOOL&lt;/a&gt;&amp;nbsp;generates
   a 512 bits output, &lt;a href="http://en.wikipedia.org/wiki/RIPEMD-160"&gt;RIPEMD&lt;/a&gt;, uses
   160, 128 or&amp;nbsp;320 bits output, but I want to focus in the S&lt;a href="http://en.wikipedia.org/wiki/SHA-2"&gt;HA-2&lt;/a&gt;,&amp;nbsp;function
   that generates&amp;nbsp;256, 512 bits ouputs, because there is available API in Microsoft.NET
   framework.
&lt;/p&gt;
&lt;p&gt;
   The main classes that implements this cryptografic algorithms are:
&lt;/p&gt;
&lt;ul&gt;
   &lt;li&gt;
      &lt;font size=2&gt;System.Security.Cryptography.&lt;/font&gt;&lt;font color=#008080 size=2&gt;SHA256Managed&lt;/font&gt; 
   &lt;li&gt;
      &lt;font color=#008080&gt;&lt;font color=#003300&gt;System.Security.Cryptography.&lt;/font&gt;&lt;font color=#008080 size=2&gt;SHA384Managed&lt;/font&gt;&lt;/font&gt; 
   &lt;li&gt;
      &lt;font size=2&gt; 
      &lt;p&gt;
         System.Security.Cryptography.
      &lt;/font&gt;&lt;font color=#008080 size=2&gt;SHA512Managed&lt;/font&gt;&gt;
   &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
   &lt;font color=#008080&gt;&lt;font size=2&gt;&lt;font color=#000000&gt;Now to the implementations. The
   following code below shows you an example how to use this function in porpuse to encrypt
   a password or just confidential data that you want to store hashed:&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
   &lt;font color=#008080&gt;&lt;font size=2&gt;&lt;font color=#000000&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;byte&lt;/span&gt;[]
   data, encryptedBytes;&lt;br&gt;
   &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt; hashedPassword &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt;.Empty;&lt;br&gt;
   &lt;br&gt;
   data &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; Encoding.Default.GetBytes(plainPassword);&lt;br&gt;
   System.Security.Cryptography.SHA256 sha2 &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; System.Security.Cryptography.SHA256Managed();&lt;br&gt;
   encryptedBytes &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; sha2.TransformFinalBlock(data,
   0, data.Length);&lt;br&gt;
   &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;foreach&lt;/span&gt; (&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;byte&lt;/span&gt; b &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;in&lt;/span&gt; sha2.Hash)&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;hashedPassword += Convert.ToString(b, 16).ToUpper().PadLeft(2, '0');&lt;br&gt;
   &lt;br&gt;
   sha2.Clear();&lt;br&gt;
   &lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//
   hashedPassword holds the hashed string&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   &lt;font face=Verdana size=2&gt;This example above encript the plain pasword using SHA-2
   algorithm.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
   &lt;font face=Verdana size=2&gt;The following example uses a &lt;strong&gt;salt &lt;/strong&gt;which
   comes to help reduce the risk of dictionary attacks, the code appends random bytes
   (so-called "salt") to the original plain text before generating hashes. Please keep
   in mind that salt can only help against prebuilt dictionaries. If an intruder gets
   access to your system and uses a brute force attack, salt will not provide much value.&lt;/font&gt;
&lt;/p&gt;
&lt;font face="Courier New" size=2&gt; 
&lt;p&gt;
   &lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt; hashedPassword &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt;.Empty;&lt;br&gt;
   &lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//generate
   a random salt value by using the following code&lt;/span&gt;
   &lt;br&gt;
   &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;byte&lt;/span&gt;[]
   salt &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;byte&lt;/span&gt;[32];&lt;br&gt;
   System.Security.Cryptography.RNGCryptoServiceProvider.Create().GetBytes(salt);&lt;br&gt;
   &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;byte&lt;/span&gt;[]
   salt &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; Encoding.Default.GetBytes(userName);&lt;br&gt;
   &lt;br&gt;
   &lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//Convert
   the plain string password into bytes&lt;/span&gt;
   &lt;br&gt;
   &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;byte&lt;/span&gt;[]
   plainPasswordBytes &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; System.Text.UnicodeEncoding.Unicode.GetBytes(plainPassword);&lt;br&gt;
   &lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//
   Append salt to password before hashing&lt;/span&gt;
   &lt;br&gt;
   &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;byte&lt;/span&gt;[]
   combinedBytes &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;byte&lt;/span&gt;[plainPasswordBytes.Length &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;+&lt;/span&gt; salt.Length];&lt;br&gt;
   System.Buffer.BlockCopy(plainPasswordBytes, 0, combinedBytes, 0, plainPasswordBytes.Length);&lt;br&gt;
   System.Buffer.BlockCopy(salt, 0, combinedBytes, plainPasswordBytes.Length, salt.Length);&lt;br&gt;
   &lt;br&gt;
   &lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//Create
   hash for the password + salt&lt;/span&gt;
   &lt;br&gt;
   System.Security.Cryptography.HashAlgorithm hashAlgo &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; System.Security.Cryptography.SHA256Managed();&lt;br&gt;
   &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;byte&lt;/span&gt;[]
   hash &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; hashAlgo.ComputeHash(combinedBytes);&lt;br&gt;
   &lt;br&gt;
   &lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//Append
   the salt to the hash &lt;/span&gt;
   &lt;br&gt;
   &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;byte&lt;/span&gt;[]
   hashPlusSalt &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;byte&lt;/span&gt;[hash.Length &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;+&lt;/span&gt; salt.Length];&lt;br&gt;
   System.Buffer.BlockCopy(hash, 0, hashPlusSalt, 0, hash.Length);&lt;br&gt;
   System.Buffer.BlockCopy(salt, 0, hashPlusSalt, hash.Length, salt.Length);&lt;br&gt;
   &lt;br&gt;
   &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;foreach&lt;/span&gt; (&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;byte&lt;/span&gt; b &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;in&lt;/span&gt; hashPlusSalt)&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;hashedPassword += Convert.ToString(b, 16).ToUpper().PadLeft(2, '0');&lt;br&gt;
   &lt;br&gt;
   &lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//
   hashedPassword holds the hashed string&lt;/span&gt;&lt;/span&gt;
&lt;/font&gt;&gt;
&lt;p&gt;
   &lt;font face=Verdana size=2&gt;That's it, now use it properly and try to avoid as much
   as you can from brut attacking...&lt;/font&gt;&gt;&gt;&gt;&gt;&lt;font color=#008080&gt;&lt;font size=2&gt;
&lt;/p&gt;
&gt;&gt;&lt;img width="0" height="0" src="http://www.eranachum.com/aggbug.ashx?id=49045260-a0da-4375-9106-dcb77b035a4c" /&gt;</description>
      <category>Security</category>
    </item>
  </channel>
</rss>