哈希密码

什么是哈希函数? (What is a Hash function?)

It’s an algorithm that maps an input of arbitrary length to a unique output of fixed length, this value is known as HASH, FINGERPRINT or DIGEST.

这是一种将任意长度的输入映射到固定长度的唯一输出的算法,该值称为HASH,FINGERPRINT或DIGEST。

It is usually used to verify the integrity of data, in fact, digital signature algorithms are applied to the DIGEST and not to the entire document.

它通常用于验证数据的完整性,实际上,数字签名算法应用于DIGEST,而不应用于整个文档。

什么是碰撞? (What are collisions?)

Every input of HASH functions supposed to be mapped to a different output (DIGEST) but this is not always true, it’s possible to find two messages that may produce the same result, in this case, we have found a collision. That’s not all because for each message there are infinite collisions.

HASH函数的每个输入都应该映射到不同的输出(DIGEST),但这并不总是正确的,有可能找到两条可能产生相同结果的消息,在这种情况下,我们发现了冲突。 这还不是全部,因为每条消息都有无限的冲突。

所以呢? (So what?)

Security of HASH functions is based on the fact it’s very hard to find collisions knowing the hashed message. This is fundamental, let’s suppose we have digitally signed a document, someone knowing it may compute a variant disadvantageous for us, that collides that is to say it produces the same DIGEST.

HASH函数的安全性基于这样一个事实,即在知道哈希消息的情况下很难发现冲突。 这是基础,假设我们已经对文档进行了数字签名,有人知道该文档可能会对我们产生不利影响的变体,发生冲突,也就是说它产生相同的DIGEST。

So when using a HASH function we have to be sure it’s computationally impossible to find a collision, this safety is based on the birthday paradox.

因此,在使用哈希函数时,我们必须确保在计算上不可能找到碰撞,这种安全性是基于生日悖论。

什么是生日悖论? (What is the Birthday paradox?)

It is based on the question: “How many people have I to consider, to have a probability greater than the 50% to have at least 2 people born on the same day?

它基于以下问题:“ 我要考虑多少人,同一天出生至少2个人的概率大于50%?

So we have to consider couples of people, given n people, we can compute the total amount of couples using the simple combination formula :

因此,我们必须考虑一对夫妇,给定n个人,我们可以使用简单的组合公式计算夫妇的总数:

where n indicates the number of people a k the size of the group, in our case a couple so 2.

其中n表示人数等于小组人数的k ,在本例中为2。

With 57 people the probability that two of them are born on the same day is 99% considering we have 1596 couples and the day in a year are 365, so skipping calculations, the answer is 23 (253 couples)

考虑到我们有1596对夫妇,并且一年中的一天是365对,因此有57个人的两个人在同一天出生的概率为99%,因此跳过计算,答案是23(253对夫妇)

哈希函数中的生日悖论 (Birthday paradox in Hash function)

The same thinking can be applied in HASH functions, and it’s known that we have a probability greater than 50% of finding a collision for 2^n/2 possible inputs, where n stands for the number of bits composing the DIGEST.

可以在HASH函数中应用相同的思路,并且众所周知,对于2 ^ n / 2个可能的输入,我们有大于50%的概率找到碰撞,其中n代表组成DIGEST的位数。

Here’s a table showing Bits and the number of values to consider.

下表显示了位数和要考虑的值数。

Image By opine.me
图片来自opine.me

生日袭击 (Birthday attack)

It consists of computing n/2 variants of the original document to find a collision. That’s because it’s important to use at least a 256-bit DIGEST.

它由计算原始文档的n / 2个变体来查找冲突。 这是因为至少要使用256位DIGEST很重要。

身份验证和哈希 (Authentication and Hashing)

Hashing is very good to store password because its transformation is mathematically irreversible, and they are deterministic.

哈希存储密码非常好,因为它的转换在数学上是不可逆的,并且是确定性的

A deterministic function is a function that given the same input always produces the same output. Obviously this is a must in authentication because it would be a big problem if a password may log in to different accounts.

确定性函数是给定相同输入总是产生相同输出的函数。 显然,这是身份验证中必须的,因为如果密码可以登录到其他帐户,这将是一个大问题。

So when saving user credentials we store the username and the hashed password in the DB. When the user logs in, we hash the password sent and compare it to the hash connected with the provided username. If the hashed password and the stored hash match, we have a valid login.

因此,在保存用户凭据时,我们将用户名和哈希密码存储在数据库中。 当用户登录时,我们对发送的密码进行哈希处理,并将其与与提供的用户名连接的哈希进行比较。 如果哈希密码和存储的哈希密码匹配,则我们具有有效的登录名。

我应该使用它们来存储密码吗? (Should I use them to store passwords?)

The short answer is yes but …

简短的答案是,但是……

In recent times it’s advised to avoid hashing to store passwords because it’s a fast operation not meant to be computationally fast by reducing password safety. For example, modern hardware could compute billions of SHA-256 per second. Instead of a fast function, we need a function that is slow at hashing passwords to bring attackers almost to a halt.

在最近的时间里,建议避免散列存储密码,因为这是一项快速操作,并不意味着通过降低密码安全性来实现计算速度快。 例如,现代硬件每秒可以计算数十亿个SHA-256 。 除了快速功能之外,我们还需要一个散列密码速度较慢的功能,以使攻击者几乎无法使用。

It’s common to use hash functions like bcrypt (Blowfish-crypt) which is an adaptive function: the iteration count of rounds can be increased to make it slower, so it remains resistant to brute force attacks even with increasing computation power.

通常使用像bcrypt (Blowfish-crypt)这样的散列函数,这是一种自适应函数:可以增加回合的迭代次数以使其变慢,因此即使提高了计算能力,它仍然可以抵抗暴力攻击。

结论 (Conclusions)

Let’s recap what we’ve learned through this article:

让我们回顾一下通过本文中学到的内容:

  • The core purpose of hashing is to create a fingerprint of data to assess data integrity.哈希的核心目的是创建数据指纹以评估数据完整性。
  • Hashing functions take arbitrary inputs and transform them into outputs of a fixed length.散列函数采用任意输入并将其转换为固定长度的输出。
  • Hashing is not sufficient to protect passwords for mass exploitation, it’s safer to use cryptographic salts.散列不足以保护密码以供大规模利用,而使用加密盐则更安全。
  • MD5 and SHA-1 have been reported as being vulnerable due to collisions. The SHA-2 family stands as a better option.

    据报道, MD5SHA-1由于碰撞而容易受到攻击。 SHA-2系列是更好的选择。

  • SHA family is not ideal to store password because it’s very fast so vulnerable to brute-force attacks, it’s better to use functions like bcrypt

    SHA系列不是理想的存储密码,因为它非常快,容易受到暴力攻击,因此最好使用bcrypt之类的功能

翻译自: https://medium.com/swlh/hashing-birthday-and-passwords-254756df55b7

哈希密码


http://www.taodudu.cc/news/show-5031045.html

相关文章:

  • C# 文件哈希码比较
  • java 哈希码
  • C# 对象哈希码
  • 哈希码 总结
  • hashcode值指的是什么_哈希码值是什么?什么是哈希码?
  • 浅谈哈希码
  • java 中的哈希码
  • Java哈希码
  • 哈希值 哈希码_什么是哈希? 哈希码如何工作-带有示例
  • 哈希码总结:
  • LCD接口设计系列二:基于LVDS接口屏的硬件电路设计
  • Mipi 接口 和 LVDS 接口区别
  • LVDS接口分类与数据格式
  • RK3399Pro LVDS接口触摸屏调试
  • 常用算法的伪代码
  • c语言常用算法归纳,C语言常用算法
  • C++经典排序算法总结
  • 样本、文库、重复、lane、run - 二代测序原理及名词解释
  • 关于出版社、学术期刊、学术会议、IF影响因子、中科院分区、SCI等概念之间的联系
  • 【学术相关】年度重磅|从2020年中科院分区表看IEEE期刊投稿
  • 11.17 Vue判断输入是否为数字
  • JS判断是否为数字或为空
  • javascript 中怎么判断为数字类型
  • js判断是否为数字 排除掉空
  • 基于数字孪生概念,开启精细化城市管理模式
  • 数字化住宅小区对计算机网络有需求,数字化住宅小区与智能建筑.pdf
  • 数字化园区建设
  • 大数据技术助推数字化智慧城市管理平台的搭建
  • 数字城市及网络化管理技术
  • el-input maxlength失效问题

哈希密码_哈希生日和密码相关推荐

  1. 密码学哈希函数_哈希函数在密码学中的应用

    密码学哈希函数 A Hash Function is a mathematical function that converts a numerical value into another comp ...

  2. python 哈希表_哈希表哪家强?编程语言找你来帮忙!

    点击关注上方"五分钟学算法", 设为"置顶或星标",第一时间送达干货. 转自编程技术宇宙 哈希表华山论剑 比特宇宙编程语言联合委员会准备举办一次大会,主题为哈希 ...

  3. 除留余数法构造哈希表_哈希表算法原理

    基本概念 哈希表(Hash Table)是一种根据关键字直接访问内存存储位置的数据结构.通过哈希表,数据元素的存放位置和数据元素的关键字之间建立起某种对应关系,建立这种对应关系的函数称为哈希函数. 哈 ...

  4. 获取令牌密码_如何真正存储用户密码和api令牌(即密码)

    获取令牌密码 A cliché in posts detailing password storage schemes is to finish by telling the syadmins and ...

  5. arcgis超级工具密码_浏览器的自动保存密码是如何将我们的密码泄露的?

    开局我们先来回答一个小问题,你注册了多少的账号密码?设置了多少不同的密码?又有多少密码是相同的?讲道理,这很难回答.不知道你们平常会不会把一些账号密码让浏览器自动保存,下次直接点击就可以登入了,非常方 ...

  6. svn php改客户端密码_记录VisualSVNServer配置在线密码修改功能

    VisualSVN Server使用的是64位版 查看对应的apache版本号是 2.2.32. 这个版本需要使用php5.5以下的,且需要使用64位的php. 下载php 5.4 的64位版本. 配 ...

  7. openwrt首次登录密码_什么是路由器登录密码 路由器登录密码介绍【详解】

    "无线路由器的无线wifi(网络)密码是登录密码吗?"最近看到网上有不少网友在咨询这个问题,或者是把无线wifi密码当作登录密码遇到无法登录的问题,在这里小编觉得有必要跟大家讲解一 ...

  8. win10删除开机密码_讲解win10忘记开机密码

    U盘启动盘来修改密码,这项操作是比较繁锁,因为制作U盘启动盘需要比较常的时间,而且还需要一台可以正常使用的电脑,这个操作都是对技能比较高的.当然了如果您对电脑感兴趣也可以试一试这个方法的.这篇文章主要 ...

  9. 阿里云 mysql 修改密码_阿里云mysql修改密码

    MYSQL的密码我们并不经常修改,但有时我们会忘记密码需要修改,还会将密码更改为自己更容易记住的!下面介绍两种更改mysql密码的方法 方法一: 此方法主要是记得旧密码然后更改为新的密码 1)先输入m ...

最新文章

  1. C和C++安全编码笔记:整数安全
  2. 请问,关闭子窗口提示错误,大家遇到这样的问题吗?
  3. java 接口工程_Java工程师(15)抽象类与接口
  4. 居然有人撸了一个网易云音乐云村,高手在民间!
  5. gpu浮点计算能力floaps_聊聊 GPU 峰值计算能力
  6. BZOJ2299 HAOI2011向量(数论)
  7. textmetric结构
  8. [.net 面向对象程序设计深入](4)MVC 6 —— 谈谈MVC的版本变迁及新版本6.0发展方向...
  9. poj 3258 River Hopscotch 二分答案
  10. C#看书笔记_02 核心C#
  11. 在线CSV转SQL工具
  12. 使用 classList API
  13. 使用cxf开发REST服务
  14. java如何对一个表达式开根号_java实现开根号的运算
  15. IGRP中的RTP、Neighbor Discovery协议及Time总结
  16. 盘点百位富豪读过的大学:土鳖比海龟更有优势
  17. 还在手写CURD代码?这三件套任意一套都能免去手写CURD确定不来看看?——JPA+MP+TK 免手写CURD三件套
  18. 千氪公开课第一期|如何实现写作收益的最大化?-千氪
  19. 数据存储板学习资料第286篇:基于6U VPX 的mSATA高性能数据存储板
  20. 为什么说“仁者不忧”?

热门文章

  1. NASM import win32api
  2. C/C++中string和vector的一些扩展
  3. 苹果发布 iOS14.3 准正式版,是否升级的建议
  4. 时尚秀9元港韩混搭服饰K847弃用职业模特 让真实的女人上封面
  5. 动还是不动:鼠标无线充电技术大盘点
  6. SpringBoot小彩蛋
  7. Keyboard 软键盘阻挡输入框爬坑指南
  8. cadencesxstrace.exe修复工具C++.rar
  9. 金融危机下 保险信息化聚焦什么?
  10. 无法连接ssh的原因