Returns a SHA1 hash of a given plaintext : SHA1Managed « Security « C# / C Sharp






Returns a SHA1 hash of a given plaintext

  
//---------------------------------------------------------------------
//  This file is part of the Background Motion solution.
// 
//  Copyright (C) Mindscape (TM).  All rights reserved.
//  http://www.mindscape.co.nz
// 
//  THIS CODE AND INFORMATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY
//  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
//  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//  PARTICULAR PURPOSE.
//---------------------------------------------------------------------

using System;
using System.Security.Cryptography;
using System.Text;

namespace Mindscape.BackgroundMotion.Core.Utilities
{
  /// <summary>
  /// Helper class which provides functions for assisting with hashing values
  /// </summary>
  public static class Hasher
  {
    /// <summary>
    /// Returns a SHA1 hash of a given plaintext
    /// </summary>
    public static string GetSHA1Hash(string plaintext)
    {
      return BitConverter.ToString(new SHA1CryptoServiceProvider()
        .ComputeHash(Encoding.Default.GetBytes(plaintext)))
        .Replace("-", String.Empty);
    }
  }
}

   
    
  








Related examples in the same category

1.new SHA1Managed()
2.Encrypt SHA1
3.Encrypt SHA256
4.SHA256 crypt
5.Marshal Str
6.Get SHA1 for a string
7.Get SHA256 for a string
8.Get SHA38 for a string
9.Get SHA512 for a string
10.Encrypts a string using the SHA256 algorithm.