Fix Swift 3 bug

This commit is contained in:
Amir Abbas
2017-09-24 15:37:00 +03:30
parent 5800c9a2ec
commit 42b879d4e2
+12 -4
View File
@@ -115,10 +115,18 @@ extension SHA2Variant32 {
result.reserveCapacity(hh.count / 4)
Self.resultingArray(hh).forEach {
let item = $0.bigEndian
result.append(UInt8(truncatingIfNeeded: item))
result.append(UInt8(truncatingIfNeeded: item >> 8))
result.append(UInt8(truncatingIfNeeded: item >> 16))
result.append(UInt8(truncatingIfNeeded: item >> 24))
#if swift(>=4.0)
result.append(UInt8(truncatingIfNeeded: item))
result.append(UInt8(truncatingIfNeeded: item >> 8))
result.append(UInt8(truncatingIfNeeded: item >> 16))
result.append(UInt8(truncatingIfNeeded: item >> 24))
#else
result.append(UInt8(item))
result.append(UInt8((item >> 8) & 0xFF))
result.append(UInt8((item >> 16) & 0xFF))
result.append(UInt8((item >> 24) & 0xFF))
#endif
}
return result
}