Java tutorial
//package com.java2s; import java.math.BigInteger; public class Main { /** * Transforms a number String to a byte array * @param in number String * @return */ public static byte[] NumStringToBytes(String in) { BigInteger num = new BigInteger(in); byte[] bytes = num.toByteArray(); if (bytes.length > 0) { if (bytes[0] == 0) { byte[] cuttedByte = new byte[bytes.length - 1]; System.arraycopy(bytes, 1, cuttedByte, 0, bytes.length - 1); return cuttedByte; } } return num.toByteArray(); } }