当我使用盐腌的CRYPT_MD5加密我的密码时正在加密什么? [英] What is being encrypted when I use a salted CRYPT_MD5 to encrypt my password?

查看:119
本文介绍了当我使用盐腌的CRYPT_MD5加密我的密码时正在加密什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



但是,当我使用php crypt()函数时,特别是在使用字符串数字加密的结果CRYPT_MD5(它已打开,我检查过了)用盐,假设它返回的md5散列不像md5散列。



例如:



如果我使用md5字符串'password',那么:

  $ pass = md5('password'); 
echo $ pass;
// 5f4dcc3b5aa765d61d8327deb882cf99

如果我使用CRYPT_MD5,它由'$ 1 $'前缀和'$'后缀盐盐':

  $ pass = crypt('password','$ 1 $ $盐'); 
echo $ pass;
//$1$salt$qJH7.N4xYta3aEG/dfqo/0

现在,算法和使用的盐如期望的那样显示,'$ 1 $'显示CRYPT_MD5被使用,并且盐在$符号之间显示为'盐'。

然而,

..最后一个$符号之后的哈希密码看起来不像一个md5 ...它有斜杠和全停止。



为什么它会散列它办法?这是不是一个真正的MD5?



请问你是否需要我澄清这一点。

解决方案


  1. MD5是一种不加密的散列算法。
  2. MD5的输出是128位数据。您的第一个示例是将128位编码为32位十六进制数字(每位数4位)。第二个例子是在crypt字母表中。0-9A-Za-z - 每个字符6位的21个字符。

有关crypt算法的更多详细信息,请参阅 http://www.gnu.org/软件/ libtool / manual / libc / crypt.html


Using md5 on a string always produces an alpha-numeric encrypted result, ie: no symbols.

However, when I using the php crypt() function, specifically the CRYPT_MD5 (and it is on, I've checked) with a salt, the supposed md5 hash it returns does not look like an md5 hash.

For example:

if I md5 the string 'password', I get:

$pass = md5('password');
echo $pass;
//5f4dcc3b5aa765d61d8327deb882cf99

if I use CRYPT_MD5, which is denoted by the '$1$' prefix and the '$' suffix with the salt being 'salt':

$pass = crypt('password', '$1$salt$');
echo $pass;
//$1$salt$qJH7.N4xYta3aEG/dfqo/0

Now, the algorithm and salt used are shown as expected, '$1$' shows that the CRYPT_MD5 was used and the salt is shown to be 'salt' as between the $ signs.

However.. the hashed password after that last $ sign does not look like an md5... it has slashes and full-stops in it.

Why does it hash it this way? Is this not a real md5?

Please ask if you need me to clarify any of this. Ugh.

解决方案

  1. MD5 is a hashing algorithm not encryption.
  2. The output of MD5 is 128 bits of data. Your first example is encoding the 128 bits as 32 Hexadecimal digits (4-bits per digit). The second example is in the crypt alphabet ./0-9A-Za-z - 21 chars at 6 bits per char.

For more details on the crypt algorithm see http://www.gnu.org/software/libtool/manual/libc/crypt.html

这篇关于当我使用盐腌的CRYPT_MD5加密我的密码时正在加密什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆