当 Perl 5.8.1 出来时,它添加了 hash randomization .当 Perl 5.8.2 出现时,我想,除非存在环境变量 ( PERL_HASH_SEED
),否则它删除了哈希随机化。现在好像我被严重误认为
PERL_HASH_SEED=$SEED perl -MData::Dumper -e 'print Dumper{map{$_,1}"a".."z"}'
无论
$SEED
的值如何,总是回退相同的键顺序.哈希随机化是否完全消失了,我做错了什么,还是这是一个错误?
最佳答案
见 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.
所以随机化并不总是发生,只有在 perl 检测到它需要时才会发生。
关于perl - Perl 5 中的哈希随机化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6685019/