最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
哈希(不可逆)加密通用类库函数
时间:2022-07-02 12:05:22 编辑:袖梨 来源:一聚教程网
using System;
using System.IO;
using System.Security.Cryptography;
namespace Common
{
///
///Copyright (C), 2004, kwklover(邝伟科)
///File name:Hasher.cs
///Author:邝伟科 Version:1.0 Date:2004年4月22日
///Description:哈希(不可逆)加密通用类库函数
///
public class Hasher
{
private byte[] _HashKey; //哈希密钥存储变量
private string _HashText; //待加密的字符串
public Hasher()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
///
/// 哈希密钥
///
public byte[] HashKey
{
set
{
_HashKey=value;
}
get
{
return _HashKey;
}
}
///
/// 需要产生加密哈希的字符串
///
public string HashText
{
set
{
_HashText=value;
}
get
{
return _HashText;
}
}
///
/// 使用HMACSHA1类产生长度为 20 字节的哈希序列。需提供相应的密钥,接受任何大小的密钥。
///
///
public string HMACSHA1Hasher()
{
byte[] HmacKey=HashKey;
byte[] HmacData=System.Text.Encoding.UTF8.GetBytes(HashText);
HMACSHA1 Hmac = new HMACSHA1(HmacKey);
CryptoStream cs = new CryptoStream(Stream.Null, Hmac, CryptoStreamMode.Write);
cs.Write(HmacData, 0, HmacData.Length);
using System.IO;
using System.Security.Cryptography;
namespace Common
{
///
///Copyright (C), 2004, kwklover(邝伟科)
///File name:Hasher.cs
///Author:邝伟科 Version:1.0 Date:2004年4月22日
///Description:哈希(不可逆)加密通用类库函数
///
public class Hasher
{
private byte[] _HashKey; //哈希密钥存储变量
private string _HashText; //待加密的字符串
public Hasher()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
///
/// 哈希密钥
///
public byte[] HashKey
{
set
{
_HashKey=value;
}
get
{
return _HashKey;
}
}
///
/// 需要产生加密哈希的字符串
///
public string HashText
{
set
{
_HashText=value;
}
get
{
return _HashText;
}
}
///
/// 使用HMACSHA1类产生长度为 20 字节的哈希序列。需提供相应的密钥,接受任何大小的密钥。
///
///
public string HMACSHA1Hasher()
{
byte[] HmacKey=HashKey;
byte[] HmacData=System.Text.Encoding.UTF8.GetBytes(HashText);
HMACSHA1 Hmac = new HMACSHA1(HmacKey);
CryptoStream cs = new CryptoStream(Stream.Null, Hmac, CryptoStreamMode.Write);
cs.Write(HmacData, 0, HmacData.Length);
相关文章
- 《职场浮生记》卡牌模组推荐 06-15
- 《纸嫁衣4红丝缠》全章节图文攻略 06-15
- 《这城有良田》奖率三军课业加点攻略 06-15
- 《纸嫁衣2奘铃村》全章节攻略汇总 06-15
- 《王者荣耀》夺宝保底次数介绍 06-15
- 《向僵尸开炮》百分比宝石选择推荐 06-15