2
0
Эх сурвалжийг харах

Workaround for broken bitwise operations (rdar://18060945)

Marcin Krzyżanowski 11 жил өмнө
parent
commit
f7a98c063e

+ 8 - 3
CryptoSwift/CryptoHashBase.swift

@@ -33,9 +33,14 @@ public class CryptoHashBase {
         return tmpMessage
     }
     
-    internal func reverseBytes(value: UInt32) -> UInt32 {
-        return (value & 0x000000FF) << 24 | (value & 0x0000FF00) << 8 |
-            (value & 0x00FF0000) >> 8  | (value & 0xFF000000) >> 24;
+    internal func reverseByte(value: UInt32) -> UInt32 {
+        // rdar://18060945 - not working since Xcode6-Beta6, need to split in two variables
+        // return = ((value & 0x000000FF) << 24) | ((value & 0x0000FF00) << 8) | ((value & 0x00FF0000) >> 8)  | ((value & 0xFF000000) >> 24);
+        
+        // workaround
+        var tmp1 = ((value & 0x000000FF) << 24) | ((value & 0x0000FF00) << 8)
+        var tmp2 = ((value & 0x00FF0000) >> 8)  | ((value & 0xFF000000) >> 24)
+        return tmp1 | tmp2
     }
     
     internal func rotateLeft(x:UInt32, _ n:UInt32) -> UInt32 {