Perl 5中的哈希随机化 [英] Hash randomization in Perl 5

查看:224
本文介绍了Perl 5中的哈希随机化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当Perl 5.8.1出来时,它添加了哈希随机化。当Perl 5.8.2出现时,我想,除非存在环境变量( PERL_HASH_SEED ),否则它将删除哈希随机数。现在看起来好像我被严重误解为

  PERL_HASH_SEED = $ SEED perl -MData :: Dumper -e'print Dumper { map {$ _,1}a..z}'

不管$ $ SEED 的值如何,相同的键排序。

哈希随机化是否完全消失,我正在做些什么错了,还是这是一个错误? 算法复杂性攻击:


在Perl 5.8.1中,哈希函数被随机扰动伪随机种子,这使得生成这样顽皮的散列键更困难。 [...]但是自5.8.2开始,如果内部检测到病理数据的插入,仅用于单独的哈希。


因此,随机化并不总是会发生,只有当perl检测到它是需要的。


When Perl 5.8.1 came out it added hash randomization. When Perl 5.8.2 came out, I thought, it removed hash randomization unless an environment variable (PERL_HASH_SEED) was present. It now seems as if I am gravely mistaken as

PERL_HASH_SEED=$SEED perl -MData::Dumper -e 'print Dumper{map{$_,1}"a".."z"}'

Always kicks back the same key ordering regardless of the value of $SEED.

Did hash randomization go completely away, am I doing something wrong, or is this a bug?

解决方案

See Algorithmic Complexity Attacks:

In Perl 5.8.1 the hash function is randomly perturbed by a pseudorandom seed which makes generating such naughty hash keys harder. [...] but as of 5.8.2 it is only used on individual hashes if the internals detect the insertion of pathological data.

So randomization doesn't always happen, only when perl detects that it's needed.

这篇关于Perl 5中的哈希随机化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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