Android String to Hex String Convert str2HexStrExt(String str)

Here you can find the source of str2HexStrExt(String str)

Description

str Hex Str Ext

Declaration

public static String str2HexStrExt(String str) 

Method Source Code

//package com.java2s;

public class Main {
    public static String str2HexStrExt(String str) {
        char[] chars = "0123456789ABCDEF".toCharArray();
        StringBuilder sb = new StringBuilder("");
        byte[] bs = str.getBytes();
        int bit;//from   w w  w .  j  a  v  a 2 s.c  o  m
        for (int i = 0; i < bs.length; i++) {
            bit = (bs[i] & 0x0f0) >> 4;
            sb.append(chars[bit]);
            bit = bs[i] & 0x0f;
            sb.append(chars[bit]);
        }
        return sb.toString();
    }
}

Related

  1. toHex(String txt)
  2. toHex(String txt)
  3. parseHexStr2Byte(String hexStr)
  4. stringToHex(String string)
  5. str2HexStr(String str)