Change sha1 mutation hash to use a separator between strings
* When concatenating strings together to hash you need to use a separator that does not exist in the strings, otherwise you can easily get duplicate hashes, eg: Digest::SHA1.hexdigest('ab' + 'c') # => "a9993e364706816aba3e25717850c26c9cd0d89d" Digest::SHA1.hexdigest('a' + 'bc') # => "a9993e364706816aba3e25717850c26c9cd0d89d" Using a null character as a separator works around this problem: Digest::SHA1.hexdigest('a' + 0.chr + 'bc') # => "0b2749668f0ea8df8a630da13f0d218709efd5ca" Digest::SHA1.hexdigest('ab' + 0.chr + 'c') # => "dbdd4f85d8a56500aa5c9c8a0d456f96280c92e5"
This commit is contained in:
parent
c3c0e06c86
commit
4856ed5251
1 changed files with 1 additions and 1 deletions
|
@ -97,7 +97,7 @@ module Mutant
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def sha1
|
def sha1
|
||||||
Digest::SHA1.hexdigest(subject.identification + source)
|
Digest::SHA1.hexdigest(subject.identification + 0.chr + source)
|
||||||
end
|
end
|
||||||
memoize :sha1
|
memoize :sha1
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue