Examples of Hex


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

    assertArrayEquals(expected, KeyUtils.makeEntryKey(hash, type, col));
  }

  @Test
  public void makeOutKeySHA1() throws Exception {
    final Hex hex = new Hex();
    final byte[] hash =
      hex.decode("64fa477898e268fd30c2bfe272e5a016f5ec31c4".getBytes());
    final byte type = 1;
    final byte[] col = "vassalengine.org/VASSAL 3.1.15".getBytes();

    // It's neat that I have to cast one-byte numeric literals to bytes.
    // Thanks, Java!
View Full Code Here

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

    assertArrayEquals(expected, KeyUtils.makeEntryKey(hash, type, col));
  }

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

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

    assertArrayEquals(hash, KeyUtils.getHash(rowKey));
  }

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

    assertEquals(KeyUtils.MD5_LEN, KeyUtils.getHashLength(rowKey));
  }
View Full Code Here

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

    assertEquals(KeyUtils.MD5_LEN, KeyUtils.getHashLength(rowKey));
  }

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

    assertArrayEquals(hash, KeyUtils.getHash(rowKey));
  }
View Full Code Here

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

    assertArrayEquals(hash, KeyUtils.getHash(rowKey));
  }

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

    assertEquals(KeyUtils.SHA1_LEN, KeyUtils.getHashLength(rowKey));
  }
View Full Code Here

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

    assertEquals(KeyUtils.SHA1_LEN, KeyUtils.getHashLength(rowKey));
  }

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

    assertArrayEquals(entryID, KeyUtils.getFsEntryID(rowKey));
  }
View Full Code Here

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

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

    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

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

* @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

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

* @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
TOP
Copyright © 2018 www.massapi.com. 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.