KostyeFromHelen
19. Шифрование SHA на C#
23.03.2012 07:10:11

using System.Security.Cryptography;
namespace ConsoleApplication1
{   
class Program   
{       


static void Main(string[] args)       
{           
Console.WriteLine(HashCode("Hello World"));       
}


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




Теги: SHA на C# | шифрование на C#


 



Программируем на C#, интересные статьи, книги, музыка; Костя Карпов.