.NET下的加密解密大全(1): 哈希加密
.NET有丰富的加密解密API库供我们使用,本博文总结了.NET下的Hash散列算法,并制作成简单的DEMO,希望能对大家有所帮助。
MD5
[csharp]
using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;
namespace EncryptAndDecrypt
{
public class MD5
{
public byte[] Hash(byte[] data)
{
System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create();
return md5.ComputeHash(data);
}
}
}
SHA1
[csharp]
using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;
namespace EncryptAndDecrypt
{
public class SHA1:IHash
{
public byte[] Hash(byte[] data)
{
System.Security.Cryptography.SHA1 sha1 = System.Security.Cryptography.SHA1.Create();
return sha1.ComputeHash(data);
}
}
}
SHA256
[csharp]
using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;
namespace EncryptAndDecrypt
{
public class SHA256:IHash
{
public byte[] Hash(byte[] data)
{
System.Security.Cryptography.SHA256 sha256= System.Security.Cryptography.SHA256.Create();
return sha256.ComputeHash(data);
}
}
}
SHA384
[csharp]
using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;
namespace EncryptAndDecrypt
{
public class SHA384:IHash
{
public byte[] Hash(byte[] data)
{
System.Security.Cryptography.SHA384 sha384 = System.Security.Cryptography.SHA384.Create();
return sha384.ComputeHash(data);
}
}
}
SHA512
[csharp]
using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;
namespace EncryptAndDecrypt
{
public class SHA512:IHash
{
public byte[] Hash(byte[] data)
{
System.Security.Cryptography.SHA512 sha512 = System.Security.Cryptography.SHA512.Create();
return sha512.ComputeHash(data);
}
}
}
.NET下的加密解密大全(1): 哈希加密的更多相关文章
- .NET下的加密解密大全(3):非对称加密
本博文列出了.NET下常用的非对称加密算法,并将它们制作成小DEMO,希望能对大家有所帮助. RSA[csharp]static string EnRSA(string data,string pub ...
- .NET下的加密解密大全(2):对称加密
本博文列出了.NET下常用的对称加密算法,并将它们制作成小DEMO,希望能对大家有所帮助. 公共代码[csharp]static byte[] CreateKey(int num) { byt ...
- python下RSA加密解密以及跨平台问题
Reference: http://www.cnblogs.com/luchanghong/archive/2012/07/18/2596886.html 项目合作需要,和其他网站通信,消息内容采用 ...
- Java加密解密大全
ChinaSEI系列讲义(By 郭克华) Java加密解密方法大全 如果有文字等小错,请多包涵.在不盈利的情况下,欢迎免费传播. 版权所有.郭克华 本讲义经 ...
- Linux下OpenSSL加密解密压缩文件(AES加密压缩文件)
OpenSSL是一个开源的用以实现SSL协议的产品,它主要包括了三个部分:密码算法库.应用程序.SSL协议库.Openssl实现了SSL协议所需要的大多数算法.下面介绍使用Openssl进行文件的对称 ...
- CentOS下Vim加密解密文本
CentOS用vim/vi给文件加密和解密 一. 利用 vim/vi 加密: 优点:加密后,如果不知道密码,就看不到明文,包括root用户也看不了: 缺点:很明显让别人知道加密了,容易让别人把加密的文 ...
- Python下RSA加密/解密, 签名/验证
原文是py2环境,而我的环境是py3,所以对原代码做了修改:decode(), encode() import rsa # 生成密钥 (pubkey, privkey) = rsa.newkeys(1 ...
- C#加密解密大全
1.方法一 (不可逆加密) public string EncryptPassword(string PasswordString,string PasswordFormat ) { ...
- python下RSA 加密/解密,签名/验证
基于win7 + python3.4 原文是py2环境,而我的环境是py3,所以对原代码做了修改:decode(), encode() import rsa # 生成密钥 (pubkey, privk ...
随机推荐
- WordPress mb.miniAudioPlayer插件多个跨站脚本漏洞
漏洞名称: WordPress mb.miniAudioPlayer插件多个跨站脚本漏洞 CNNVD编号: CNNVD-201309-469 发布时间: 2013-09-26 更新时间: 2013-0 ...
- v8 javascript engine
https://code.google.com/p/v8-wiki/wiki/BuildingWithGYP vs2013git v8 http://github.com/v8/v8-git-mirr ...
- 字符串编码、Base64字符串 互转
/// <summary> /// 将字符串编码为Base64字符串 /// </summary> /// <param name="str"& ...
- SLua 中使用 Lua 5.3 的编译工程
2016-03-05 更新: 之前编译的库,在 Android 下 Lua_Number 和 Lua_Integer 被编译为了32位,导致从 C# 到 Lua 过程中有64位到32位整型转换会出现溢 ...
- Web---演示servlet技术(servlet生命周期),解决中文乱码问题
本节讲解决中文乱码问题的4种方法. 还有更好的方法,也就是用过滤器,这里就不演示了,博主目前也不会~呼♪(^∇^*)~过段时间才会学. servlet生命周期演示: index.jsp: <%@ ...
- 2D游戏编程1--windows编程模型
一.创建一个windows程序步骤 1.创建一个windows类 2.创建一个事件处理程序 3.注册windows类 4.用之前创建的windows类创建一个窗口 5.创建一个主事件循环 二.存储 ...
- JNI 从C文件向Java文件传递多个参数
JNI C主函数 #include <jni.h> #include <string.h> #include <android/log.h> #include &q ...
- Hadoop 中 Eclipse 的配置
先启动Hadoop守护进程,进入hadoop安装目录,执行bin/start-all.sh 主要是为了之后能正确测试 Ubuntu中下载安装Eclipse,执行sudo apt-get install ...
- 蔡勒(Zeller)公式
蔡勒(Zeller)公式,是一个计算星期的公式,随便给一个日期,就能用这个公式推算出是星期几. W =[ [c/4] - 2c + y + [y/4] + [13 * (m+1) / 5] + d - ...
- xom报错 Exception in thread "main" java.net.UnknownHostException: file
Exception in thread "main" java.net.UnknownHostException: file at java.net.AbstractPlainSo ...