最新下载
热门教程
- 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);
相关文章
- 致命公司传送器有什么用 传送器作用介绍 12-06
- dota2骑士之倚有什么用 骑士之倚效果介绍 12-06
- 致命公司雷达增强器怎么用 雷达发射器使用教学 12-06
- 恋爱吗我家的猫会后空翻第一章全流程攻略 12-06
- 星球重启球球宠物心愿解锁条件一览 12-06
- 星球重启冰霜琥珀在哪 冰霜琥珀位置一览 12-06