I need to return a 12-position token in Base64

0

I need a token of 12 positions in Base64, so when I generate a hex it has exactly 32 digits.

At first I convert to byte []

byte[] tok = Base64. decodeBase64(preToken.getBytes());

The idea is that with this token I generate a hexadecimal of Strings that has 32 characters.

For this I use this method

private static String stringHexa(byte[] bytes) {
        StringBuilder s = new StringBuilder();
        for (int i = 0; i < bytes.length; i++) {
            int parteAlta = ((bytes[i] >> 4) & 0xf) << 4;
            int parteBaixa = bytes[i] & 0xf;
            if (parteAlta == 0) s.append('0');
            s.append(Integer.toHexString(parteAlta | parteBaixa));
        }
        return s.toString();
    }

My difficulty is in generating the 12 positions in Base64.

    
asked by anonymous 14.12.2018 / 13:42

0 answers