title: PHP equivalent of .NET Code
body: <p>I am converting .net project to PHP . But unable to convert the following code:</p>
  
  <pre><code>public static string HashString(string value)
      {
          SHA1 hasher = new SHA1CryptoServiceProvider();
  
          UTF8Encoding enc = new UTF8Encoding();
  
          byte[] hashInBytes = hasher.ComputeHash(enc.GetBytes(value));
  
          return Convert.ToBase64String(hashInBytes);
      }
  </code></pre>
  
  <p>So far I have done this but result is not same:</p>
  
  <pre><code>function HashString($str) {
    return base64_encode(sha1($str));
  }
  </code></pre>
  
  <p>Please help, thanks.</p>