본문 바로가기
개발/java

byteArrayToHex

by 가시죠 2021. 1. 17.
반응형

byteArrayToHex

private static String byteArrayToHex(byte[] encrypted) {

        if(encrypted == null || encrypted.length ==0){
            return null;
        }

        StringBuffer sb = new StringBuffer(encrypted.length * 2);
        String hexNumber;

        for(int x=0; x<encrypted.length; x++){
            hexNumber = "0" + Integer.toHexString(0xff & encrypted[x]);
            sb.append(hexNumber.substring(hexNumber.length() - 2));
        }

        return sb.toString();
    }

 

반응형

댓글