Example usage for org.bouncycastle.crypto.digests SHA1Digest SHA1Digest

List of usage examples for org.bouncycastle.crypto.digests SHA1Digest SHA1Digest

Introduction

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

Prototype

public SHA1Digest(byte[] encodedState) 

Source Link

Document

State constructor - create a digest initialised with the state of a previous one.

Usage

From source file:com.sun.midp.crypto.SHA.java

License:Open Source License

/** 
 * Clones the MessageDigest object./*w  w  w.jav a2 s .c o  m*/
 * @return a clone of this object
 */
public Object clone() {
    return new SHA(new SHA1Digest(impl));
}

From source file:TorJava.Node.java

License:Open Source License

/**
 * calculate the forward digest/*  www  .j a v  a 2s  . c o m*/
 * 
 * @param data
 * @return a four-byte array containing the digest
 */
byte[] calc_forward_digest(byte[] data) {
    Logger.logCrypto(Logger.RAW_DATA, "Node.calc_forward_digest() on:\n" + Encoding.toHexString(data, 100));
    sha1_forward.update(data, 0, data.length);
    byte[] digest = new byte[20];
    SHA1Digest copyOldState = new SHA1Digest(sha1_forward); // ugly fix
                                                            // around
                                                            // bouncy-castle's
                                                            // behaviour on
                                                            // hashes
    sha1_forward.doFinal(digest, 0);
    sha1_forward = copyOldState;
    Logger.logCrypto(Logger.VERBOSE, " result:\n" + Encoding.toHexString(digest, 100));
    byte[] four_bytes = new byte[4];
    System.arraycopy(digest, 0, four_bytes, 0, 4);
    return four_bytes;
}

From source file:TorJava.Node.java

License:Open Source License

/**
 * calculate the backward digest/*from  w ww.  ja  va2  s.  c  o m*/
 * 
 * @param data
 * @return a four-byte array containing the digest
 */
byte[] calc_backward_digest(byte[] data) {
    Logger.logCrypto(Logger.RAW_DATA, "Node.calc_backward_digest() on:\n" + Encoding.toHexString(data, 100));
    sha1_backward.update(data, 0, data.length);
    byte[] digest = new byte[20];
    SHA1Digest copyOldState = new SHA1Digest(sha1_backward); // ugly fix
                                                             // around
                                                             // bouncy-castle's
                                                             // behaviour
                                                             // on hashes
    sha1_backward.doFinal(digest, 0);
    sha1_backward = copyOldState;
    Logger.logCrypto(Logger.RAW_DATA, " result:\n" + Encoding.toHexString(digest, 100));
    byte[] four_bytes = new byte[4];
    System.arraycopy(digest, 0, four_bytes, 0, 4);
    return four_bytes;
}