Here you can find the source of getByteList(String nomal, boolean isDecode)
private static List<byte[]> getByteList(String nomal, boolean isDecode) throws Exception
//package com.java2s; //License from project: Open Source License import javax.xml.bind.DatatypeConverter; import java.util.ArrayList; import java.util.List; public class Main { private static final String CHARACTER_SET = "UTF-8"; /**/*from www . j a va 2s . c o m*/ * seed 128bit */ private static List<byte[]> getByteList(String nomal, boolean isDecode) throws Exception { List<byte[]> byteList = new ArrayList<byte[]>(); byte[] tempByte = null; if (isDecode) { tempByte = DatatypeConverter.parseBase64Binary(nomal); } else { tempByte = nomal.getBytes(CHARACTER_SET); } int needBlankLength = 0; if (tempByte.length % 16 != 0) { needBlankLength = 16 - (tempByte.length % 16); } byte[] newTempByte = new byte[tempByte.length + needBlankLength]; for (int i = 0; i < tempByte.length; i++) { newTempByte[i] = tempByte[i]; } int inListByteIdx = 0; byte[] inListByte = new byte[16]; for (int i = 0; i < newTempByte.length; i++) { inListByte[inListByteIdx] = newTempByte[i]; inListByteIdx++; if ((i + 1) % 16 == 0 && i != 0) { byteList.add(inListByte); inListByte = new byte[16]; inListByteIdx = 0; } } return byteList; } }