Method: SJCL::BitArray.compare
- Defined in:
- lib/sjcl/bit_array.rb
.compare(arr1, arr2) ⇒ Object
Compare two SJCL type BitArrays in a predictable amount of time
145 146 147 148 149 150 151 152 153 154 |
# File 'lib/sjcl/bit_array.rb', line 145 def self.compare(arr1, arr2) x = 0 return false if arr1.length != arr2.length arr1 = convertToSigned32(arr1) arr2 = convertToSigned32(arr2) (arr1.length).times do |i| x = arr1[i] ^ arr2[i] end return (x == 0) end |