HashAlgorithm哈希算法信息
HashAlgorithm
表示所有加密哈希算法实现均必须从中派生的基类
继承层次结构
System.Object
System.Security.Cryptography.HashAlgorithm
System.Security.Cryptography.KeyedHashAlgorithm
System.Security.Cryptography.MD5
System.Security.Cryptography.RIPEMD160
System.Security.Cryptography.SHA1
System.Security.Cryptography.SHA256
System.Security.Cryptography.SHA384
System.Security.Cryptography.SHA512
[ComVisibleAttribute(true)] public abstract class HashAlgorithm : IDisposable, ICryptoTransform
示例代码
static void Main() {HashAlgorithm md5 = MD5.Create();Console.WriteLine("\n MD5.Create():");Console.WriteLine("GetTypeName = " + md5.GetType().Name);Console.WriteLine("ToString = " + md5.ToString());HashAlgorithm md5Cng = new MD5Cng();Console.WriteLine("\n new MD5Cng():");Console.WriteLine("GetTypeName = " + md5Cng.GetType().Name);Console.WriteLine("ToString = " + md5Cng.ToString());HashAlgorithm md5Csp = new MD5CryptoServiceProvider();Console.WriteLine("\n new MD5CryptoServiceProvider():");Console.WriteLine("GetTypeName = " + md5Csp.GetType().Name);Console.WriteLine("ToString = " + md5Csp.ToString());HashAlgorithm sha1 = new SHA1Managed();Console.WriteLine("\n new SHA1Managed():");Console.WriteLine("GetTypeName = " + sha1.GetType().Name);Console.WriteLine("ToString = " + sha1.ToString());HashAlgorithm sha1Cng = new SHA1Cng();Console.WriteLine("\n new SHA1Cng():");Console.WriteLine("GetTypeName = " + sha1Cng.GetType().Name);Console.WriteLine("ToString = " + sha1Cng.ToString());HashAlgorithm sha1Csp = new SHA1CryptoServiceProvider();Console.WriteLine("\n new SHA1CryptoServiceProvider():");Console.WriteLine("GetTypeName = " + sha1Csp.GetType().Name);Console.WriteLine("ToString = " + sha1Csp.ToString());HashAlgorithm sha256 = new SHA256Managed();Console.WriteLine("\n new SHA256Managed():");Console.WriteLine("GetTypeName = " + sha256.GetType().Name);Console.WriteLine("ToString = " + sha256.ToString());HashAlgorithm sha384 = new SHA384Cng();Console.WriteLine("\n new SHA384Cng():");Console.WriteLine("GetTypeName = " + sha384.GetType().Name);Console.WriteLine("ToString = " + sha384.ToString());HashAlgorithm sha512 = new SHA512CryptoServiceProvider();Console.WriteLine("\n new SHA512CryptoServiceProvider():");Console.WriteLine("GetTypeName = " + sha512.GetType().Name);Console.WriteLine("ToString = " + sha512.ToString());Console.ReadLine(); }
运行结果:
MD5.Create(): GetTypeName = MD5CryptoServiceProvider ToString = System.Security.Cryptography.MD5CryptoServiceProvidernew MD5Cng(): GetTypeName = MD5Cng ToString = System.Security.Cryptography.MD5Cngnew MD5CryptoServiceProvider(): GetTypeName = MD5CryptoServiceProvider ToString = System.Security.Cryptography.MD5CryptoServiceProvidernew SHA1Managed(): GetTypeName = SHA1Managed ToString = System.Security.Cryptography.SHA1Managednew SHA1Cng(): GetTypeName = SHA1Cng ToString = System.Security.Cryptography.SHA1Cngnew SHA1CryptoServiceProvider(): GetTypeName = SHA1CryptoServiceProvider ToString = System.Security.Cryptography.SHA1CryptoServiceProvidernew SHA256Managed(): GetTypeName = SHA256Managed ToString = System.Security.Cryptography.SHA256Managednew SHA384Cng(): GetTypeName = SHA384Cng ToString = System.Security.Cryptography.SHA384Cngnew SHA512CryptoServiceProvider(): GetTypeName = SHA512CryptoServiceProvider ToString = System.Security.Cryptography.SHA512CryptoServiceProvider
运行时信息:
md5 {System.Security.Cryptography.MD5CryptoServiceProvider}[System.Security.Cryptography.MD5CryptoServiceProvider]: {System.Security.Cryptography.MD5CryptoServiceProvider}CanReuseTransform: trueCanTransformMultipleBlocks: trueHash: “md5.Hash”引发了“System.NullReferenceException”类型的异常HashSize: 128InputBlockSize: 1OutputBlockSize: 1md5Cng {System.Security.Cryptography.MD5Cng}[System.Security.Cryptography.MD5Cng]: {System.Security.Cryptography.MD5Cng}CanReuseTransform: trueCanTransformMultipleBlocks: trueHash: “md5Cng.Hash”引发了“System.NullReferenceException”类型的异常HashSize: 128InputBlockSize: 1OutputBlockSize: 1md5Csp {System.Security.Cryptography.MD5CryptoServiceProvider}[System.Security.Cryptography.MD5CryptoServiceProvider]: {System.Security.Cryptography.MD5CryptoServiceProvider}CanReuseTransform: trueCanTransformMultipleBlocks: trueHash: “md5Csp.Hash”引发了“System.NullReferenceException”类型的异常HashSize: 128InputBlockSize: 1OutputBlockSize: 1sha1 {System.Security.Cryptography.SHA1Managed}[System.Security.Cryptography.SHA1Managed]: {System.Security.Cryptography.SHA1Managed}CanReuseTransform: trueCanTransformMultipleBlocks: trueHash: “sha1.Hash”引发了“System.NullReferenceException”类型的异常HashSize: 160InputBlockSize: 1OutputBlockSize: 1sha1Cng {System.Security.Cryptography.SHA1Cng}[System.Security.Cryptography.SHA1Cng]: {System.Security.Cryptography.SHA1Cng}CanReuseTransform: trueCanTransformMultipleBlocks: trueHash: “sha1Cng.Hash”引发了“System.NullReferenceException”类型的异常HashSize: 160InputBlockSize: 1OutputBlockSize: 1sha1Csp {System.Security.Cryptography.SHA1CryptoServiceProvider}[System.Security.Cryptography.SHA1CryptoServiceProvider]: {System.Security.Cryptography.SHA1CryptoServiceProvider}CanReuseTransform: trueCanTransformMultipleBlocks: trueHash: “sha1Csp.Hash”引发了“System.NullReferenceException”类型的异常HashSize: 160InputBlockSize: 1OutputBlockSize: 1sha256 {System.Security.Cryptography.SHA256Managed}[System.Security.Cryptography.SHA256Managed]: {System.Security.Cryptography.SHA256Managed}CanReuseTransform: trueCanTransformMultipleBlocks: trueHash: “sha256.Hash”引发了“System.NullReferenceException”类型的异常HashSize: 256InputBlockSize: 1OutputBlockSize: 1sha384 {System.Security.Cryptography.SHA384Cng}[System.Security.Cryptography.SHA384Cng]: {System.Security.Cryptography.SHA384Cng}CanReuseTransform: trueCanTransformMultipleBlocks: trueHash: “sha384.Hash”引发了“System.NullReferenceException”类型的异常HashSize: 384InputBlockSize: 1OutputBlockSize: 1sha512 {System.Security.Cryptography.SHA512CryptoServiceProvider}[System.Security.Cryptography.SHA512CryptoServiceProvider]: {System.Security.Cryptography.SHA512CryptoServiceProvider}CanReuseTransform: trueCanTransformMultipleBlocks: trueHash: “sha512.Hash”引发了“System.NullReferenceException”类型的异常HashSize: 512InputBlockSize: 1OutputBlockSize: 1
MD5
表示的抽象类的所有实现均从中 MD5 哈希算法继承
继承层次结构
System.Object
System.Security.Cryptography.HashAlgorithm
System.Security.Cryptography.MD5
System.Security.Cryptography.MD5Cng
System.Security.Cryptography.MD5CryptoServiceProvider
[ComVisibleAttribute(true)] public abstract class MD5 : HashAlgorithm
MD5.Create()
创建一个实例的默认实现 MD5 哈希算法
MD5Cng
提供 CNG (下一代加密技术) 实现的 MD5 (消息摘要 5) 128 位哈希算法
继承层次结构
System.Object
System.Security.Cryptography.HashAlgorithm
System.Security.Cryptography.MD5
System.Security.Cryptography.MD5Cng
[HostProtectionAttribute(SecurityAction.LinkDemand, MayLeakOnAbort = true)] public sealed class MD5Cng : MD5
MD5CryptoServiceProvider
计算 MD5 哈希值的输入数据使用加密服务提供商 (CSP) 提供的实现。 此类不能被继承
继承层次结构
System.Object
System.Security.Cryptography.HashAlgorithm
System.Security.Cryptography.MD5
System.Security.Cryptography.MD5CryptoServiceProvider
[ComVisibleAttribute(true)] public sealed class MD5CryptoServiceProvider : MD5
SHA1
计算 SHA1 输入数据的哈希值
继承层次结构
System.Object
System.Security.Cryptography.HashAlgorithm
System.Security.Cryptography.SHA1
System.Security.Cryptography.SHA1Cng
System.Security.Cryptography.SHA1CryptoServiceProvider
System.Security.Cryptography.SHA1Managed
[ComVisibleAttribute(true)] public abstract class SHA1 : HashAlgorithm
SHA1Cng
提供的下一代加密技术 (CNG) 实现的安全哈希算法 (SHA)
继承层次结构
System.Object
System.Security.Cryptography.HashAlgorithm
System.Security.Cryptography.SHA1
System.Security.Cryptography.SHA1Cng
[HostProtectionAttribute(SecurityAction.LinkDemand, MayLeakOnAbort = true)] public sealed class SHA1Cng : SHA1
SHA1CryptoServiceProvider
计算 SHA1 哈希值的输入数据使用加密服务提供商 (CSP) 提供的实现。 此类不能被继承
继承层次结构
System.Object
System.Security.Cryptography.HashAlgorithm
System.Security.Cryptography.SHA1
System.Security.Cryptography.SHA1CryptoServiceProvider
[ComVisibleAttribute(true)] public sealed class SHA1CryptoServiceProvider : SHA1
SHA1Managed
计算 SHA1 使用托管的库的输入数据的哈希值
继承层次结构
System.Object
System.Security.Cryptography.HashAlgorithm
System.Security.Cryptography.SHA1
System.Security.Cryptography.SHA1Managed
[ComVisibleAttribute(true)] public class SHA1Managed : SHA1
HashAlgorithm哈希算法信息相关推荐
- 21 | 哈希算法(上):如何防止数据库中的用户信息被脱库?
问题:对于用户信息中的密码,你会如何存储用户密码?仅仅 MD5 加密一下存储就够了吗?--哈希算法 什么是哈希算法 哈希算法的定义和原理:将任意长度的二进制值串映射为固定长度的二进制值串,这个映射的规 ...
- 哈希算法(一)---如何防止数据库中的用户信息被脱库?
目录 什么是哈希算法? 应用一:安全加密 应用二:唯一标识 应用三:数据校验 应用四:散列函数 解答开篇 内容小结 课后思考 还记得 2011 年 CSDN 的"脱库"事件吗?当时 ...
- 国产哈希算法WJLHA(一):开源与应用
一.哈希算法现状 目前常见的Hash算法有MD5.SHA.MAC.CRC等.MD5信息摘要算法(MD5 Message-Digest Algorithm)[1],一种被广泛使用的密码散列算法,可以产生 ...
- 算法:哈希算法的应用场景
什么是哈希算法 将任意长度的二进制值串映射为固定长度的二进制值串,这个映射的规则就是哈希算法,而通过原始数据映射之后得到的二进制值串就是哈希值. 一个优秀的哈希算法应该满足下面几个条件: 从哈希值不能 ...
- 用拉链法实现哈希算法的运算
package lirui.find;import java.util.LinkedList;/*** Created by lirui on 14-8-13.* 用拉链法实现哈希算法的运算*/ pu ...
- 五分钟带你了解哈希算法
导读: 当新人在学区块链技术的时候,都会听到哈希和哈希算法,这似乎是无处不在的安全性保证.例如比特币或者以太坊这种运行去中心化网络和共识的机器,都会有上万个节点通过P2P连接,并且需要"无需 ...
- 一次失败的面试,复习一次一致性哈希算法
来自公众号:孤独烟 本文故事绝对真实,如有雷同,绝对不是巧合! 于是呢,烟哥提前十分钟在公司里头找了一个厕所的坑位,然后进去随手一锁门-.(以下省略10000字)- 唉- 我竟然又带薪上厕所了,而且上 ...
- 区块链课程笔记-第一课哈希算法在加密中的应用
哈希密码,哈希碰撞的含义,即我们有一个值x经过哈希变换得到y. 输出y是有限的,2的256次幂,但是输入x是无限的.输入值的一点点变动,输出的值都会变动.但是如果输入不同的值,而得到了相同的值,那么就 ...
- 识别哈希算法类型hash-identifier
识别哈希算法类型hash-identifier hash-identifier是一款哈希算法识别工具.通过该工具,用户可以识别哈希值所使用的哈希算法.确定算法后,就可以采用对应的工具进行xx.执行该命 ...
最新文章
- C++多线程实现生产者消费者模式
- PHP exec xargs 不执行,关于 ‘--exec’ 参数( find 命令)及介绍 ‘xargs ’命令区别(新版)...
- Composer的简单安装与使用
- [编写高质量代码:改善java程序的151个建议]建议69 列表相等只需关心元素相等...
- template_1
- [codevs 1916] 负载平衡问题
- python二维散点分布图_深入理解皮尔逊相关系数amp;python代码
- 算法题:判断字符串是否为 ipv4 地址
- python网络爬虫系列(四)——requests模块
- java 风车_Java兴趣编程-转动的大风车
- 读书笔记:陈希孺:概率论与数理统计:2014.01.02
- Fragstats软件使用及其景观生态学意义
- macOS 安装老旧版本的 adobe 应用
- PaddleNLP登顶FewCLUE小样本学习榜单;AutoPrompt自动化提示功能直接带你原地起飞
- c# 回调先进先出_Stack和Queue:后进先出和先进先出
- 《SLA by Short brain》—学好英语口语的终极法宝!
- Proximal Gradient for LASSO
- 你的善良必须有点锋芒
- php c端,蛋白测序(N端,C端测序)
- 解决报错:The Module Root specified is not a module according to Intellij
热门文章
- 快递单号查询,物流查询,教你筛选快递代收件
- 【路径规划】基于A星算法实现机器人走迷宫路径规划含Matlab源码
- 信用评分卡--R语言
- matlabrgb和波长的换算_matlab RGB到HSI的彩色转换及实现
- 如何获取到一个app里所使用的所有图标icon等资源文件
- 【docker】docker的安装教程
- 为php文件建立ip地址,IP地址查询网站的建立(基于qqwry数据库建立)
- Struts2第七篇【介绍拦截器、自定义拦截器、执行流程、应用】
- Nginx+tomcat+redis实现高可用负载均衡session共享集群+redis哨兵监控
- Caused by: java.lang.LinkageError: loader constraint violation: loader (instance of org/apache/catal