最新下载
热门教程
- 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);
相关文章
- 鸣潮仇远培养攻略-鸣潮仇远怎么养 03-22
- 秘塔猫写作网页版直达-秘塔写作猫官网入口 03-22
- 鸣潮3.2声骸管理方案套装码合集-声骸管理方案是设置弃置还是锁 03-22
- 鸣潮3.2版本更新内容-鸣潮「于影中启明的决心」3.2版本内容说明 03-22
- 归环抽卡概率有多高 03-22
- duyin抖音官网首页-网页版入口地址 03-22