title: Decrypt SHA1 value with C#
body: <p>I have a PHP web service that I've discovered is passing my C# a SHA-1 encrupted value. The sample data that is passed to me is "8cb2237d0679ca88db6464eac60da96345513964" which I know translates to "12345".</p>
  
  <p>How do I translate the hashed value back to "12345" with code similar to the following</p>
  
  <pre><code>public static string HashCode(string str)
  {
  string rethash = "";
  try
  {
  
        System.Security.Cryptography.SHA1 hash = System.Security.Cryptography.SHA1.Create();
         System.Text.ASCIIEncoding encoder = new System.Text.ASCIIEncoding();
         byte[] combined = encoder.GetBytes(str);
         hash.ComputeHash(combined);
         rethash = Convert.ToBase64String(hash.Hash);
  }
  catch (Exception ex)
  {
         string strerr = "Error in HashCode : " + ex.Message;
  }
  return rethash;
  }
  </code></pre>
  
  <ul>
  <li>EDIT *</li>
  </ul>
  
  <p>Here is some RUBY code that is also workig with "8cb2237d0679ca88db6464eac60da96345513964" and "12345"</p>
  
  <pre><code>require "digest/sha1"
  class User
    attr_accessor :password
    def initialize(password)
      @password = hash_password(password)
    end
    def hash_password(password)
      Digest::SHA1.hexdigest(password)
    end
    def valid_password?(password)
      @password == hash_password(password)
    end
  end
  u = User.new("12345")
  p u.password # =&gt; "8cb2237d0679ca88db6464eac60da96345513964"
  p u.valid_password?("not valid") # =&gt; false
  p u.valid_password?("12345") # =&gt; true
  </code></pre>