Java Hash String hashCodeToString(byte[] hash)

Here you can find the source of hashCodeToString(byte[] hash)

Description

Converts the given bytes to a hex String.

License

Apache License

Parameter

Parameter Description
hash The bytes.

Return

The String.

Declaration

private static String hashCodeToString(byte[] hash) 

Method Source Code

//package com.java2s;
/**************************************************************************
 *
 * Gluewine Core Module//w  w  w  .  ja  v  a  2 s. co m
 *
 * Copyright (C) 2013 FKS bvba               http://www.fks.be/
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 ***************************************************************************/

public class Main {
    /**
     * Converts the given bytes to a hex String.
     *
     * @param hash The bytes.
     * @return The String.
     */
    private static String hashCodeToString(byte[] hash) {
        StringBuffer sb = new StringBuffer("");
        for (int i = 0; i < hash.length; i++)
            sb.append(Integer.toString((hash[i] & 0xff) + 0x100, 16).substring(1));

        return sb.toString();
    }
}

Related

  1. hashCode2(String str)
  2. hashCode64(String s)
  3. hashCode64(String s)
  4. hashCodeIgnoreCase(String a)
  5. hashCodeOfStringArray(String[] stringArray)
  6. hashCodeToString(long code)
  7. hasHeirarchy(String xpath)
  8. hasHexOrDecLongUrnSuffix(String value)
  9. hasHexPrefix(final String hexSymbols)