Convert byte To Hex String - Android java.lang

Android examples for java.lang:Hex

Description

Convert byte To Hex String

Demo Code

import android.text.TextUtils;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.util.AbstractCollection;
import java.util.Collection;
import java.util.Iterator;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main{

    private static String byteToHexString(byte b) {
        int n = b;
        if (n < 0)
            n = 256 + n;/*from   w  w  w.  ja v a2s.c  o m*/
        int d1 = n / 16;
        int d2 = n % 16;
        return hexDigits[d1] + hexDigits[d2];
    }

}

Related Tutorials