Mega Code Archive

 
Categories / C# / Security
 

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);     }   } }