当前位置:网站首页>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 ︎
边栏推荐
- .NET C#基础(7):接口 - 人如何和猫互动
- 【离散数学期复习系列】五、一些特殊的图
- JMeter 中如何实现接口之间的关联?
- 2022第十四届南京国际人工智能产品展会
- [logodetection data set processing] (3) divide the training set into multiple folders by category
- Why should the R & D effectiveness team of Internet companies be independent? When is independence?
- AutoCAD - set text spacing and line spacing
- Ada Logics:CRI-O整体安全审计项目
- How the WordPress administrator user name was leaked
- CRM对企业以及销售员有哪些帮助?
猜你喜欢

Binary tree and figure 1

2022 the 15th Nanjing International Digital Industry Expo

如何实现erp外网连接?

2022 the 15th Nanjing International Industrial Automation Exhibition

二分查找详解

【LogoDetection 数据集处理】(3)将训练集按照类别划分为多个文件夹

AutoRunner自动化测试工具如何创建项目-Alltesting|泽众云测试

【离散数学期复习系列】四、图

三子棋(c语言实现)

洞見科技入選「愛分析· 隱私計算廠商全景報告」,獲評金融解决方案代錶廠商
随机推荐
QT transfers the received JSON data (including Chinese) Unicode to utf8
[Discrete Mathematical period Review Series] Second and first order Logic (precate Logic)
[discrete mathematics review series] i. propositional logic
2022第十四届南京国际人工智能产品展会
Microsoft Word tutorial, how to change margins and create a newsletter column in word?
竟然还有人说ArrayList是2倍扩容,今天带你手撕ArrayList源码
LeetCode_ 21 (merge two ordered linked lists)
Why should the R & D effectiveness team of Internet companies be independent? When is independence?
2022第十五届南京国际数字化工业博览会
what‘t the meaning of “de facto“
Shutter wrap button bottomnavigationbar learning summary 4
ScrollView 初始化的时候不在最顶部?
小程序警告:Now you can provide attr `wx:key` for a `wx:for` to improve performance.
New exploration of meta company | reduce Presto latency by using alluxio data cache
Leetcode 2293. Minimax game (yes. One pass)
Does Fortran have a standard library
[cloud native | kubernetes] in depth RC, RS, daemonset, statefulset (VII)
one
[logodetection data set processing] (3) divide the training set into multiple folders by category
Is it safe to open an account in qiniu