In Swift 4.2, the language adopted a proposal that, among other things, adds randomness to the output of the hash(into: ) function implemented by Hashable types. This causes issues when using DiskStorage as all keys are hashed before being used as file names.
func makeFileName(for key: Key) -> String {
if let key = key as? String {
let fileExtension = URL(fileURLWithPath: key).pathExtension
let fileName = MD5(key)
switch fileExtension.isEmpty {
case true:
return fileName
case false:
return "\(fileName).\(fileExtension)"
}
}
var hasher = self.hasher
key.hash(into: &hasher)
return String(hasher.finalize())
}
Since hashes of identical objects vary by execution, it no longer is possible to use the hash of an object as a key for fetching objects stored in DiskStorage. Instead of using the built in Hashable functionality, an insecure hashing method such as SHA1 should be used to fix discrepancies between the hashes of identical objects between executions.
In Swift 4.2, the language adopted a proposal that, among other things, adds randomness to the output of the
hash(into: )
function implemented by Hashable types. This causes issues when using DiskStorage as all keys are hashed before being used as file names.Since hashes of identical objects vary by execution, it no longer is possible to use the hash of an object as a key for fetching objects stored in DiskStorage. Instead of using the built in Hashable functionality, an insecure hashing method such as SHA1 should be used to fix discrepancies between the hashes of identical objects between executions.