lib/ccrypto/java/utils/comparator.rb in ccrypto-java-0.1.0 vs lib/ccrypto/java/utils/comparator.rb in ccrypto-java-0.2.0

- old
+ new

@@ -9,12 +9,35 @@ def self.is_equal?(val1, val2) bval1 = to_java_bytes(val1) bval2 = to_java_bytes(val2) - bval1 == bval2 + 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 - self.singleton_class.alias_method :is_equals?, :is_equal? + class << self + alias_method :is_equals?, :is_equal? + alias_method :equals?, :is_equal? + alias_method :equal?, :is_equal? + end + #self.singleton_class.alias_method :is_equals?, :is_equal? + private + def logger + Ccrypto::Java.logger(:comparator) + end end end end