Example usage for org.apache.commons.codec.binary Hex encodeHexString

List of usage examples for org.apache.commons.codec.binary Hex encodeHexString

Introduction

In this page you can find the example usage for org.apache.commons.codec.binary Hex encodeHexString.

Prototype

public static String encodeHexString(byte[] data) 

Source Link

Document

Converts an array of bytes into a String representing the hexadecimal values of each byte in order.

Usage

From source file:eu.europa.esig.dss.TokenIdentifier.java

/**
 * Return an ID conformant to XML Id
 */
public String asXmlId() {
    return Hex.encodeHexString(tokenDigest.getValue());
}

From source file:libepg.epg.section.descriptor.networkdescriptor.NetworkNameDescriptor.java

@Override
public String toString() {
    return super.toString() + "\n" + "???? ? = "
            + Hex.encodeHexString(this.getChar_byte()) + "\n" + "???? = "
            + this.getChar_String() + "\n";
}

From source file:com.hurence.logisland.util.kura.KuraPayloadDecoder.java

/**
 * Constructor//from  www. j ava  2  s.c  o  m
 */
public KuraPayloadDecoder(final byte[] bytes) {
    this.m_bytes = bytes;
    System.out.println(Hex.encodeHexString(bytes));
}

From source file:com.titilink.common.app.EncryptDecryptUtil.java

public void testMD5() throws NoSuchAlgorithmException {
    MessageDigest md = MessageDigest.getInstance("MD5");
    md.reset();/*from w  w  w  . jav a  2 s .  co  m*/
    byte[] retArr = md.digest("this is a security string".getBytes(Charset.forName("UTF-8")));
    System.out.println(Hex.encodeHexString(retArr));

    byte[] retArr1 = md.digest("this is a security string".getBytes(Charset.forName("UTF-8")));
    System.out.println(Hex.encodeHexString(retArr1));

    byte[] retArr2 = md.digest("this is a security string.".getBytes(Charset.forName("UTF-8")));
    System.out.println(Hex.encodeHexString(retArr2));

    byte[] retArr3 = md.digest("this is a security string.".getBytes(Charset.forName("UTF-8")));
    System.out.println(Hex.encodeHexString(retArr3));
}

From source file:br.com.ingenieux.jenkins.plugins.codecommit.CodeCommitRequestSigner.java

public String getPushUrl() {
    String user = awsCredentials.getAWSAccessKeyId();

    String host = "git-codecommit." + region + ".amazonaws.com";

    String path = "/v1/repos/" + repoName;

    String scope = String.format("%s/%s/%s/%s", strDate, region, service, TERMINATOR);

    StringBuilder stringToSign = new StringBuilder();

    stringToSign.append(String.format("%s-%s\n%s\n%s\n", SCHEME, AWS_ALGORITHM, strDateTime, scope));

    stringToSign.append(DigestUtils/*  www. j av a2 s.c  om*/
            .sha256Hex(String.format("GIT\n%s\n\nhost:%s\n\nhost\n", path, host).getBytes(DEFAULT_CHARSET)));

    byte[] key = deriveKey();

    byte[] digest = hash(key, stringToSign.toString());

    String signature = Hex.encodeHexString(digest);

    String password = strDateTime.concat("Z").concat(signature);

    return String.format("%s:%s", user, password);
}

From source file:de.phoenix.util.hash.SHA1Hasher.java

public String generate(byte[] bytes) {

    try {/*from w ww  .j av a 2s  . c  o m*/
        MessageDigest ms = MessageDigest.getInstance(ALGORITHM);
        ms.update(bytes);
        return Hex.encodeHexString(ms.digest());
    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
        return null;
    }
}

From source file:net.solarnetwork.node.rfxcom.test.CommandMessageTest.java

@Test
public void encodeResetCommand() {
    CommandMessage msg = new CommandMessage(Command.Reset);
    assertNull("Data", msg.getData());
    final byte[] packet = msg.getMessagePacket();
    log.debug("Got packet: " + Hex.encodeHexString(packet));
    assertNotNull("Packet", packet);
    assertArrayEquals(TestUtils.bytesFromHexString("0D 00 00 00 00 00 00 00 00 00 00 00 00 00"), packet);
}

From source file:gobblin.kafka.serialize.MD5Digest.java

/**
 * Static method to get an MD5Digest from a binary byte representation.
 * @param md5Bytes//from  ww  w.j a  va2 s  . c o m
 * @param offset in the byte array to start reading from
 * @return a filled out MD5Digest
 */
public static MD5Digest fromBytes(byte[] md5Bytes, int offset) {
    byte[] md5BytesCopy = Arrays.copyOfRange(md5Bytes, offset, offset + MD5_BYTES_LENGTH);
    //TODO: Replace this with a version that encodes without needing a copy.
    String md5String = Hex.encodeHexString(md5BytesCopy);
    return new MD5Digest(md5String, md5BytesCopy);
}

From source file:marshalsec.gadgets.C3P0WrapperConnPool.java

public static String makeC3P0UserOverridesString(String codebase, String clazz)
        throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException,
        InvocationTargetException, IOException {

    ByteArrayOutputStream b = new ByteArrayOutputStream();
    try (ObjectOutputStream oos = new ObjectOutputStream(b)) {
        Class<?> refclz = Class.forName("com.mchange.v2.naming.ReferenceIndirector$ReferenceSerialized"); //$NON-NLS-1$
        Constructor<?> con = refclz.getDeclaredConstructor(Reference.class, Name.class, Name.class,
                Hashtable.class);
        con.setAccessible(true);//from   ww w. j  a va  2s .co m
        Reference jndiref = new Reference("Foo", clazz, codebase);
        Object ref = con.newInstance(jndiref, null, null, null);
        oos.writeObject(ref);
    }

    return "HexAsciiSerializedMap:" + Hex.encodeHexString(b.toByteArray()) + ";"; //$NON-NLS-1$
}

From source file:com.blackcrowsys.sinscrypto.ShaHasher.java

@Override
public boolean checkHash(String codeToHash, String hash) {
    digester.reset();//from w w w . j a va  2 s . c  om
    digester.update(codeToHash.getBytes());
    String generated = Hex.encodeHexString(digester.digest());
    return generated.equalsIgnoreCase(hash);
}