Compute hash for given class and all of its methods.

@param javaClass
the class
@return this object
761428
public ClassHash computeHash(JavaClass javaClass) {
        this.className = javaClass.getClassName();

        Method[] methodList = new Method[javaClass.getMethods().length];

        // Sort methods
        System.arraycopy(javaClass.getMethods(), 0, methodList, 0, javaClass.getMethods().length);
        Arrays.sort(methodList, (o1, o2) -> {
            // sort by name, then signature
            int cmp = o1.getName().compareTo(o2.getName());
            if (cmp != 0) {
                return cmp;
            }
            return o1.getSignature().compareTo(o2.getSignature());

        });

        Field[] fieldList = new Field[javaClass.getFields().length];

        // Sort fields
        System.arraycopy(javaClass.getFields(), 0, fieldList, 0, javaClass.getFields().length);
        Arrays.sort(fieldList, (o1, o2) -> {
            int cmp = o1.getName().compareTo(o2.getName());
            if (cmp != 0) {
                return cmp;
            }
            return o1.getSignature().compareTo(o2.getSignature());
        });

        MessageDigest digest = Util.getMD5Digest();

        // Compute digest of method names and signatures, in order.
        // Also, compute method hashes.
        CharsetEncoder encoder = Charset.forName("UTF-8").newEncoder();
        for (Method method : methodList) {
            work(digest, method.getName(), encoder);
            work(digest, method.getSignature(), encoder);

            MethodHash methodHash = new MethodHash().computeHash(method);
            methodHashMap.put(XFactory.createXMethod(javaClass, method), methodHash);
        }

        // Compute digest of field names and signatures.
        for (Field field : fieldList) {
            work(digest, field.getName(), encoder);
            work(digest, field.getSignature(), encoder);
        }

        classHash = digest.digest();

        return this;
    }
1122037
public MurmurHash hash(int input) {
		count++;

		input *= 0xcc9e2d51;
		input = Integer.rotateLeft(input, 15);
		input *= 0x1b873593;

		hash ^= input;
		hash = Integer.rotateLeft(hash, 13);
		hash = hash * 5 + 0xe6546b64;

		return this;
	}
1063174
public static String hash(Serializable obj) {

		if (obj == null) {
			return "";
		}
		StringBuilder hexString = new StringBuilder();
		try {

			MessageDigest m = MessageDigest.getInstance("SHA1");
			m.update(SerializationUtils.serialize(obj));

			byte[] mdbytes = m.digest();

            for (byte mdbyte : mdbytes) {
                hexString.append(Integer.toHexString(0xFF & mdbyte));
            }

		} catch (NoSuchAlgorithmException e) {
			return "";
		}
		return hexString.toString();
	}
637471
public JavaClass lookupClass(@Nonnull @DottedClassName String className) throws ClassNotFoundException {
        try {
            if (className.length() == 0) {
                throw new IllegalArgumentException("Class name is empty");
            }
            if (!ClassName.isValidClassName(className)) {
                throw new ClassNotFoundException("Invalid class name: " + className);
            }
            return Global.getAnalysisCache().getClassAnalysis(JavaClass.class,
                    DescriptorFactory.instance().getClassDescriptor(ClassName.toSlashedClassName(className)));
        } catch (CheckedAnalysisException e) {
            throw new ClassNotFoundException("Class not found: " + className, e);
        }
    }
1091106
public static ClassDescriptor getClassDescriptor(JavaClass jclass) {
        return DescriptorFactory.instance().getClassDescriptor(ClassName.toSlashedClassName(jclass.getClassName()));
    }
901177
public static int hash(int seed, Object o) {
		int result = seed;
		//If it was null then this is the result 0
		if (o == null) {
			result = hash(result, 0);
		}
		//If it wasn't an array then calculate the hashcode
		else if (!o.getClass().isArray()) {
			result = hash(result, o.hashCode());
		}
		//Otherwise loop &
		else {
			int length = Array.getLength(o);
			for (int i = 0; i < length; i++) {
				Object item = Array.get(o, i);
				result = hash(result, item);// recursive call!
			}
		}
		return result;
	}
1273831
def instance_method_hash(options)
      ChainOptions::Util.slice(options, Option::METHOD_SYMBOLS).each_with_object({}) do |(meth, value), h|
        next h[meth] = value if value.respond_to?(:call)

        h[meth] = instance.public_method(value)
      end
    end
780972
public int[] hash(Key k){
      byte[] b = k.getBytes();
      if (b == null) {
        throw new NullPointerException("buffer reference is null");
      }
      if (b.length == 0) {
        throw new IllegalArgumentException("key length must be > 0");
      }
      int[] result = new int[nbHash];
      for (int i = 0, initval = 0; i < nbHash; i++) {
	  initval = hashFunction.hash(b, initval);
	  result[i] = Math.abs(initval % maxValue);
      }
      return result;
  }
684392
private Sha256Hash calculateHash() {
        try {
            ByteArrayOutputStream bos = new UnsafeByteArrayOutputStream(HEADER_SIZE);
            writeHeader(bos);
            return Sha256Hash.wrapReversed(Sha256Hash.hashTwice(bos.toByteArray()));
        } catch (IOException e) {
            throw new RuntimeException(e); // Cannot happen.
        }
    }
254960
@Override
    public void storeClass(JavaClass javaClass) {
        if (DEBUG) {
            System.out.println("Storing class " + javaClass.getClassName() + " in repository");
        }
        JavaClass previous = nameToClassMap.put(javaClass.getClassName(), javaClass);
        if (DEBUG && previous != null) {
            System.out.println("\t==> A previous class was evicted!");
            dumpStack();
        }
        Repository tmp = org.apache.bcel.Repository.getRepository();
        if (tmp != null && tmp != this) {
            throw new IllegalStateException("Wrong/multiple BCEL repository");
        }
        if (tmp == null) {
            org.apache.bcel.Repository.setRepository(this);
        }
    }
141348
def to_hash
      out = {}
      self.class.properties.each { |p| out[hash_key(p)] = hash_value(p) }
      out
    end
1370500
public static Method[] getMethods(Class<?> beanClass) throws SecurityException {
		Method[] allMethods = METHODS_CACHE.get(beanClass);
		if (null != allMethods) {
			return allMethods;
		}

		allMethods = getMethodsDirectly(beanClass, true);
		return METHODS_CACHE.put(beanClass, allMethods);
	}
549323
function _hash() {
    var set = Array.prototype.map.call(arguments, function(v) {
        return typeof v === 'string' ? v : Object.keys(v).join(' ');
    }).join(' ');

    return set.split(/\s+/)
        .reduce(function(res, keyword) {
            res[keyword] = true;
            return res;
        }, {});
}
1020721
function hashObject (obj) {
  if (!isObject(obj)) return null;
  return shortHash(JSON.stringify(sortKeys(obj, { deep: true })));
}
13012
def hash(self):
        """"""
        if not hasattr(self, "__hash"):
            self.__hash = self._calculate_hash()
        return self.__hash
1289761
public ClassFeatureSet initialize(JavaClass javaClass) {
        this.className = javaClass.getClassName();
        this.isInterface = javaClass.isInterface();

        addFeature(CLASS_NAME_KEY + transformClassName(javaClass.getClassName()));

        for (Method method : javaClass.getMethods()) {
            if (!isSynthetic(method)) {
                String transformedMethodSignature = transformMethodSignature(method.getSignature());

                if (method.isStatic() || !overridesSuperclassMethod(javaClass, method)) {
                    addFeature(METHOD_NAME_KEY + method.getName() + ":" + transformedMethodSignature);
                }

                Code code = method.getCode();
                if (code != null && code.getCode() != null && code.getCode().length >= MIN_CODE_LENGTH) {
                    addFeature(CODE_LENGTH_KEY + method.getName() + ":" + transformedMethodSignature + ":"
                            + code.getCode().length);
                }
            }
        }

        for (Field field : javaClass.getFields()) {
            if (!isSynthetic(field)) {
                addFeature(FIELD_NAME_KEY + field.getName() + ":" + transformSignature(field.getSignature()));
            }
        }

        return this;
    }
719731
def to_hash
      index_hash = Hash.new
      index_hash["json_claz"] = self.class.name
      index_hash["id"] = id
      index_hash["code"] = code
      index_hash["amount"] = amount
      index_hash["created_at"] = created_at
      index_hash
    end