Class: Ccrypto::Java::ComparatorUtil
- Inherits:
-
Object
- Object
- Ccrypto::Java::ComparatorUtil
- Extended by:
- DataConversion
- Defined in:
- lib/ccrypto/java/utils/comparator.rb
Class Method Summary collapse
- .is_equal?(val1, val2) ⇒ Boolean (also: is_equals?, equals?, equal?)
Methods included from DataConversion
from_b64, from_b64_mime, from_hex, included, to_b64, to_b64_mime, to_bin, to_hex, to_java_bytes, to_str
Class Method Details
.is_equal?(val1, val2) ⇒ Boolean Also known as: is_equals?, equals?, equal?
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/ccrypto/java/utils/comparator.rb', line 9 def self.is_equal?(val1, val2) bval1 = to_java_bytes(val1) bval2 = to_java_bytes(val2) if bval1.length != bval2.length false else res = 0 (0...bval1.length).each do |i| res |= bval1[i] ^ bval2[i] end res == 0 end #bval1 == bval2 #logger.debug "bval1 : #{bval1.inspect}" #logger.debug "bval2 : #{bval2.inspect}" end |