Package org.apache.commons.codec.binary

Examples of org.apache.commons.codec.binary.Hex


                    //Duplicate so we don't destroy original data :)
                    ByteBuffer hexBuffer = chunk.getData().duplicate();

                    ByteBuffer charBuffer = hexBuffer.duplicate();

                    Hex hexencoder = new Hex();

                    while (hexBuffer.hasRemaining())
                    {
                        byte[] line = new byte[LINE_SIZE];

                        int bufsize = hexBuffer.remaining();
                        if (bufsize < LINE_SIZE)
                        {
                            hexBuffer.get(line, 0, bufsize);
                        }
                        else
                        {
                            bufsize = line.length;
                            hexBuffer.get(line);
                        }

                        byte[] encoded = hexencoder.encode(line);

                        try
                        {
                            String encStr = new String(encoded, 0, bufsize * 2, DEFAULT_ENCODING);
                            String hexLine = "";
View Full Code Here


     * @return
     */
    private static String displayByteFormat(Composite localComposite, byte[] byteArray, int numOfBytes,
                                            String encoding, String direction, boolean isHex)
    {
        final Hex hexeconder = new Hex();
        final byte[] encoded = hexeconder.encode(byteArray);

        int hexLength = byteArray.length * 2;
        StringBuilder sb = new StringBuilder();
        int currentBytePos = (Integer) localComposite.getData("currentBytePos");
        int startingBytePos = (Integer) localComposite.getData("startingBytePos");
View Full Code Here

                    //Duplicate so we don't destroy original data :)
                    java.nio.ByteBuffer hexBuffer = buf;

                    java.nio.ByteBuffer charBuffer = hexBuffer.duplicate();

                    Hex hexencoder = new Hex();

                    while (hexBuffer.hasRemaining())
                    {
                        byte[] line = new byte[LINE_SIZE];

                        int bufsize = hexBuffer.remaining();
                        if (bufsize < LINE_SIZE)
                        {
                            hexBuffer.get(line, 0, bufsize);
                        }
                        else
                        {
                            bufsize = line.length;
                            hexBuffer.get(line);
                        }

                        byte[] encoded = hexencoder.encode(line);

                        try
                        {
                            String encStr = new String(encoded, 0, bufsize * 2, DEFAULT_ENCODING);
                            String hexLine = "";
View Full Code Here

                    //Duplicate so we don't destroy original data :)
                    ByteBuffer hexBuffer = chunk.getData().duplicate();

                    ByteBuffer charBuffer = hexBuffer.duplicate();

                    Hex hexencoder = new Hex();

                    while (hexBuffer.hasRemaining())
                    {
                        byte[] line = new byte[LINE_SIZE];

                        int bufsize = hexBuffer.remaining();
                        if (bufsize < LINE_SIZE)
                        {
                            hexBuffer.get(line, 0, bufsize);
                        }
                        else
                        {
                            bufsize = line.length;
                            hexBuffer.get(line);
                        }

                        byte[] encoded = hexencoder.encode(line);

                        try
                        {
                            String encStr = new String(encoded, 0, bufsize * 2, DEFAULT_ENCODING);
                            String hexLine = "";
View Full Code Here

            // Compute the hmac on input data bytes
            byte[] rawHmac = mac.doFinal(value.getBytes());

            // Convert raw bytes to Hex
            byte[] hexBytes = new Hex().encode(rawHmac);

            // Covert array of Hex bytes to a String
            return new String(hexBytes, "UTF-8");
        } catch (Exception e) {
            throw new RuntimeException(e);
View Full Code Here

      long compactID = Long.parseLong(tokens[0]);

      CompactionIterators iters = new CompactionIterators();

      if (tokens.length > 1) {
        Hex hex = new Hex();
        ByteArrayInputStream bais = new ByteArrayInputStream(hex.decode(tokens[1].split("=")[1].getBytes(Constants.UTF8)));
        DataInputStream dis = new DataInputStream(bais);

        try {
          iters.readFields(dis);
        } catch (IOException e) {
View Full Code Here

     * @return
     */
    private static String displayByteFormat(Composite localComposite, byte[] byteArray, int numOfBytes,
                                            String encoding, String direction, boolean isHex)
    {
        final Hex hexeconder = new Hex();
        final byte[] encoded = hexeconder.encode(byteArray);

        int hexLength = byteArray.length * 2;
        StringBuilder sb = new StringBuilder();
        int currentBytePos = (Integer) localComposite.getData("currentBytePos");
        int startingBytePos = (Integer) localComposite.getData("startingBytePos");
View Full Code Here

          }

          StringBuilder encodedIterators = new StringBuilder();

          if (iterators != null) {
            Hex hex = new Hex();
            encodedIterators.append(",");
            encodedIterators.append(txidString);
            encodedIterators.append("=");
            encodedIterators.append(new String(hex.encode(iterators), Constants.UTF8));
          }

          return (Long.toString(flushID) + encodedIterators).getBytes(Constants.UTF8);
        }
      });
View Full Code Here

     * @return byte[] �^�ǽs�X�ᤧ�줸�հ}�C.
     */
    public static byte[] decodeFromHexString(String binaryString) throws Exception {
      byte[] data;
    try {
      data = (byte[]) new Hex().decode(binaryString);
    } catch (DecoderException e) {
      throw new Exception("�ѽX���r����פ��O���Ʀ��.");
    }
     
      return data;
View Full Code Here

        /**
         * Constructor.
         */
        public IdentifierGenerator() {
            random = new Random();
            hex = new Hex();
        }
View Full Code Here

TOP

Related Classes of org.apache.commons.codec.binary.Hex

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.