Example usage for org.bouncycastle.crypto.digests MD5Digest reset

List of usage examples for org.bouncycastle.crypto.digests MD5Digest reset

Introduction

In this page you can find the example usage for org.bouncycastle.crypto.digests MD5Digest reset.

Prototype

public void reset() 

Source Link

Document

reset the chaining variables to the IV values.

Usage

From source file:com.verhas.licensor.HardwareBinder.java

/**
 * Calculate the UUID for the machine this code is running on. To do this
 * the method lists all network interfaces that are real 'server' interfaces
 * (ignoring loop-back, virtual, and point-to-point interfaces). The method
 * takes each interface name (as a string) and hardware address into a MD5
 * digest one after the other and finally converts the resulting 128bit
 * digest into a UUID./*from   ww w  . ja v  a 2  s  .c  o  m*/
 * <p>
 * The method also feeds the local machine name into the digest.
 * <p>
 * This method relies on Java 6 methods, but also works with Java 5. However
 * the result will not be the same on Java 5 as on Java 6.
 * 
 * @return the UUID of the machine or null if the uuid can not be
 *         calculated.
 * @throws SocketException
 * @throws UnsupportedEncodingException
 * @throws UnknownHostException
 */
public UUID getMachineId() throws UnsupportedEncodingException, SocketException, UnknownHostException {
    final MD5Digest md5 = new MD5Digest();
    md5.reset();
    if (useNetwork) {
        updateWithNetworkData(md5);
    }
    if (useHostName) {
        updateWithHostName(md5);
    }
    if (useArchitecture) {
        updateWithArchitecture(md5);
    }
    final byte[] digest = new byte[16];
    md5.doFinal(digest, 0);
    return UUID.nameUUIDFromBytes(digest);
}