Package org.apache.commons.codec.binary

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


    assertArrayEquals(entryID, KeyUtils.getFsEntryID(rowKey));
  }

  @Test
  public void retrieveImageID() throws Exception {
    final Hex hex = new Hex();
    final byte[] hash = hex.decode("deadbeefdeadbeefdeadbeefdeadbeef".getBytes());
    final byte[] imgID = hex.decode("baadf00dbaadf00dbaadf00dbaadf00d".getBytes());
    final byte[] entryID = FsEntryUtils.makeFsEntryKey(imgID, "/etc/passwd".getBytes(), 17);
    final byte[] rowKey = KeyUtils.makeEntryKey(hash, KeyUtils.MD5, entryID);
   
    assertArrayEquals(imgID, KeyUtils.getImageID(rowKey));
  }
View Full Code Here


    assertArrayEquals(imgID, KeyUtils.getImageID(rowKey));
  }

  @Test
  public void isType2() throws Exception {
    final Hex hex = new Hex();
    final byte[] hash = hex.decode("deadbeefdeadbeefdeadbeefdeadbeef".getBytes());
    final byte[] imgID = hex.decode("baadf00dbaadf00dbaadf00dbaadf00d".getBytes());
    final byte[] entryID = FsEntryUtils.makeFsEntryKey(imgID, "/etc/passwd".getBytes(), 17);
    final byte[] rowKey = KeyUtils.makeEntryKey(hash, KeyUtils.MD5, entryID);

    assertEquals(true, KeyUtils.isType2(rowKey));
    assertEquals(false, KeyUtils.isType2(hash));
View Full Code Here

* @author Joel Uckelman
*/
public class HexWritableTest {
  @Test
  public void toStringTest() throws Exception {
    final Hex hex = new Hex();
    final String str = "DEADBEEF";
    final HexWritable hw = new HexWritable(hex.decode(str.getBytes()));
    assertEquals(str, hw.toString().toUpperCase());
  }
View Full Code Here

* @author Joel Uckelman
*/
public class ImmutableHexWritableTest {
  @Test
  public void toStringTest() throws Exception {
    final Hex hex = new Hex();
    final String str = "DEADBEEF";
    final ImmutableHexWritable ihw =
      new ImmutableHexWritable(hex.decode(str.getBytes()));
    assertEquals(str, ihw.toString().toUpperCase());
  }
View Full Code Here

    assertArrayEquals(expected, makeFsEntryKey(img_md5, path, dir_index));
  }

  @Test
  public void retrieveImageID() throws Exception {
    final Hex hex = new Hex();
    final byte[] hash =
      hex.decode("8a9111fe05f9815fc55c728137c5b389".getBytes());
    final byte[] key = makeFsEntryKey(hash, "/howdy/doody.jpg".getBytes(), 34);
   
    assertArrayEquals(hash, getImageID(key));
  }
View Full Code Here

      "roadrunner exterminator"
    );

    final MfgData md = new MfgData("ACME", "ACME Corporation");

    final Hex hex = new Hex();
    final byte[] sha1 =
      (byte[]) hex.decode("deadbeefdeadbeefdeadbeefdeadbeefdeadbeef");
    final byte[] md5 =
      (byte[]) hex.decode("deadbeefdeadbeefdeadbeefdeadbeef");
    final byte[] crc32 = (byte[]) hex.decode("deadbeef");

    final byte[] sha1_col = "sha1".getBytes();
    final byte[] md5_col = "md5".getBytes();
    final byte[] crc32_col = "crc32".getBytes();
    final byte[] size_col = "filesize".getBytes();
View Full Code Here

    super(bytes);
  }

  @Override
  public String toString() {
    final Hex hex = new Hex();
    final byte[] bytes = new byte[getLength()];
    System.arraycopy(getBytes(), 0, bytes, 0, bytes.length);
    return new String(hex.encode(bytes));
  }
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

          }

          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

            SecretKey secret = new SecretKeySpec(secretByte, "HMACSHA256");
            mac.init(secret);

            byte[] doFinal = mac.doFinal(dataBytes);
            byte[] hexB = new Hex().encode(doFinal);
            return new String(hexB, "utf-8");
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
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.