当前位置:网站首页>One-way hash function
One-way hash function
2022-06-10 14:49:00 【MyFreeIT】
单向散列函数
function规则
通过输入很容易计算输出,但是,通过输出反推输入,只能暴力穷举。因为欧拉定理只给出正向推导公式,没有给出反向推导公式。
- Hash value,即散列值的长度固定
- 摘要,即消息不同Hash value 不同
- 单向性,不可逆
- 计算速度快
应用场景
One-way hash function 是一种保证信息完整性的密码技术。比如存储用户的密码时,只需要存储密码的Hash value即可,验证时,只需要对比两个Hash value就可以判断输入的密码是否正确。
- 加密和解密,密码
- 接口验签,接收到的内容进行Hash value,与接收到的Hash value 进行对比,就是验签的过程。
- 完整性校验
- 云盘秒传,Upload时,根据文件信息生产Hash value,如果与服务器上的某个Hash value相等,说明已存在该文件,直接通过Hash value 关联即可。
例如:MySQL社区给出安装文件的哈希值,以便让用户下载后验证文件是否被篡改。
实现方式
Hash value(散列值 消息摘要 message digest, 指纹fingerprint),相当于消息的身份
One-way hash function(message digest function 消息摘要函数,哈希函数,杂凑函数)
source message(pre-image)
String book = "It's a book";
System.out.println(book.hashCode());
System.out.println(Integer.toHexString(book.hashCode()));
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(book.getBytes());
System.out.println(new BigInteger(1, md.digest()).toString(16));
# -1420758063
# ab50f3d1
# "It's a book" = 505fe447e3d0257ff64fbd321849928f 16个字节 / 32个字符
# "It's a book1" = fd88076e4a8161b76efd6d518bc2c1ce 16个字节 / 32个字符
其它编码和加密方式:
MessageDigest.getInstance("SHA-512") 64个字节/128个字符
#d0988c57f40e049be1aa371e1c9b58ae1bfe1028df925e6429689aff746a69e8
d9d447773d656a1df097b3def2fe36e36cf7b54a4679f486d84b0d4e675a3456
MessageDigest.getInstance("SHA-256") 32个字节/64个字符
#aa6a7c05f39dcde57599f76c92e2295d86726e4d875e426bbe388941942ffa38
MessageDigest.getInstance("SHA-1") 20个字节/40个字符
从Java9开始支持SHA-3
哈希算法
比特币协议使用的是SHA-256和RipeMD160,其中SHA-256也叫hash256和dhash,RipeMD160是在SHA-256的运算结果上再计算RipeMD160,也叫hash160。

参考文献1
单向散列加密 https://blog.51cto.com/gozhuyinglong/4058818 ︎
边栏推荐
猜你喜欢

如何实现erp外网连接?

Binary tree and Figure 2
![[discrete mathematics review series] III. concept and operation of sets](/img/b5/5c7d077490875dbe0ff4777f6b0a7a.png)
[discrete mathematics review series] III. concept and operation of sets

At the early stage of product development, do you choose to develop apps or applets?

How to implement the association between interfaces in JMeter?

This awesome low code generator is now open source!

Insight Technology a été sélectionné dans le rapport panorama des fournisseurs d'analyse de l'amour et d'informatique de la vie privée et a été évalué comme représentant des fournisseurs de solutions

Do you understand all these difficult memory problems?

Flutter Icon Stack LIsttitle... Learning summary 3

New exploration of meta company | reduce Presto latency by using alluxio data cache
随机推荐
CVPR 2022 oral | SCI: fast, flexible and robust low light image enhancement
WordPress的管理员用户名是如何泄露的
洞见科技入选「爱分析· 隐私计算厂商全景报告」,获评金融解决方案代表厂商
CVPR 2022 Oral | SCI:实现快速、灵活与稳健的低光照图像增强
[registration] to solve the core concerns of technology entrepreneurs, the online enrollment of "nebula plan open class" was opened
BigDecimal removes extra 0 at the end
[discrete mathematics review series] VI. tree
【离散数学期复习系列】二、一阶逻辑(谓词逻辑)
BigDecimal 去除末尾多余的0
Anaconda installs opencv (CV2) and uses it in the jupyter notebook
小程序网络请求Promise化
orgin框架 笔记
【Rust日报】2022-04-19 Rust异步框架的性能评估
Design tools and skills for beginners to build their own blog
NC | Wang Jun / song Mozhi combined with third-generation sequencing to analyze the structural variation and function of intestinal flora
How the WordPress administrator user name was leaked
超强实操!手把手教学Kinect深度图与RGB摄像头的标定与配准
我的第一个Go程序
华为云SRE确定性运维介绍
数仓的基本概念