57 lines
1.2 KiB
C#
57 lines
1.2 KiB
C#
|
|
using System;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.Security.Cryptography;
|
|||
|
|
namespace ZWL.Common.DEncrypt
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȫ<EFBFBD>루<EFBFBD><EBA3A8>ϣ<EFBFBD><CFA3><EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
public class HashEncode
|
|||
|
|
{
|
|||
|
|
public HashEncode()
|
|||
|
|
{
|
|||
|
|
//
|
|||
|
|
// TODO: <20>ڴ˴<DAB4><CBB4><EFBFBD><EFBFBD>ӹ<EFBFBD><D3B9>캯<EFBFBD><ECBAAF><EFBFBD><EFBFBD>
|
|||
|
|
//
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϣ<EFBFBD><CFA3><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public static string GetSecurity()
|
|||
|
|
{
|
|||
|
|
string Security = HashEncoding(GetRandomValue());
|
|||
|
|
return Security;
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20>õ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public static string GetRandomValue()
|
|||
|
|
{
|
|||
|
|
Random Seed = new Random();
|
|||
|
|
string RandomVaule = Seed.Next(1, int.MaxValue).ToString();
|
|||
|
|
return RandomVaule;
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><>ϣ<EFBFBD><CFA3><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
|||
|
|
/// </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;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|