C#獲取哈希加密生成隨機安全碼的類實例
更新時間:2015年03月26日 09:41:25 作者:feige
這篇文章主要介紹了C#獲取哈希加密生成隨機安全碼的類,涉及C#哈希加密及字符串操作的相關技巧,具有一定參考借鑒價值,需要的朋友可以參考下
本文實例講述了C#獲取哈希加密生成隨機安全碼的類。分享給大家供大家參考。具體分析如下:
這個C#類封裝了一些hash加密的功能,可以用于得到隨機哈希加密字符串使用非常方便
using System;
using System.Text;
using System.Security.Cryptography;
namespace DotNet.Utilities
{
/// <summary>
/// 得到隨機安全碼(哈希加密)。
/// </summary>
public class HashEncode
{
public HashEncode()
{
//
// TODO: 在此處添加構(gòu)造函數(shù)邏輯
//
}
/// <summary>
/// 得到隨機哈希加密字符串
/// </summary>
/// <returns></returns>
public static string GetSecurity()
{
string Security = HashEncoding(GetRandomValue());
return Security;
}
/// <summary>
/// 得到一個隨機數(shù)值
/// </summary>
/// <returns></returns>
public static string GetRandomValue()
{
Random Seed = new Random();
string RandomVaule = Seed.Next(1, int.MaxValue).ToString();
return RandomVaule;
}
/// <summary>
/// 哈希加密一個字符串,sharejs.com
/// </summary>
/// <param name="Security"></param>
/// <returns></returns>
public static string HashEncoding(string Security)
{
byte[] Value;
UnicodeEncoding Code = new UnicodeEncoding();
byte[] Message = Code.GetBytes(Security);
SHA512Managed Arithmetic = new SHA512Managed();
Value = Arithmetic.ComputeHash(Message);
Security = "";
foreach(byte o in Value)
{
Security += (int) o + "O";
}
return Security;
}
}
}
希望本文所述對大家的C#程序設計有所幫助。
winform 實現(xiàn)選擇文件和選擇文件夾對話框的簡單實例
下面小編就為大家?guī)硪黄獁inform 實現(xiàn)選擇文件和選擇文件夾對話框的簡單實例。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
2017-01-01
C# Entity Framework中的IQueryable和IQueryProvider詳解
這篇文章主要介紹了C# Entity Framework中的IQueryable和IQueryProvider詳解,本文使用實例分析這兩個接口的內(nèi)部實現(xiàn),需要的朋友可以參考下
2015-01-01 
