[Quantproject-developers] QuantProject/b1_ADT HashProvider.cs,NONE,1.1
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2004-03-21 16:21:46
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26490/b1_ADT Added Files: HashProvider.cs Log Message: Provides hashing values --- NEW FILE: HashProvider.cs --- using System; using System.Security.Cryptography; namespace QuantProject.ADT { /// <summary> /// Provides hashing values /// </summary> public class HashProvider { public HashProvider() { // // TODO: Add constructor logic here // } /// <summary> /// Returns an hash value for the string toBeHashed /// </summary> /// <param name="toBeHashed">parameter for which the hash value must be computed</param> /// <returns>Computed hash value</returns> public static string GetHashValue( string toBeHashed ) { SHA1CryptoServiceProvider sha1CryptoServiceProvider = new SHA1CryptoServiceProvider(); // converts the original string to an array of bytes byte[] bytes = System.Text.Encoding.UTF8.GetBytes( toBeHashed ); // computes the Hash, and returns an array of bytes byte[] hashBytes = sha1CryptoServiceProvider.ComputeHash( bytes ); sha1CryptoServiceProvider.Clear(); // returns a base 64 encoded string of the hash value return Convert.ToBase64String( hashBytes ); } } } |