Class JrpcgenSHA

java.lang.Object
org.acplt.oncrpc.apps.jrpcgen.JrpcgenSHA

public class JrpcgenSHA extends Object
This class implements the SHA-1 algorithm as described in "Federal Information Processing Standards Publication 180-1: Specifications for the Secure Hash Standard. April 17, 1995."
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private long
     
    private int
     
    private int
     
    private int
     
    private int
     
    private int
     
    private final int[]
    Work buffer for calculating the hash.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a new SHA-1 hashing object.
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    Retrieve the digest (that is, informally spoken, the "hash value").
    long
    Return first 64 bits of hash digest for use as a serialization UID, etc.
    private void
    Process a single block.
    void
    Reset the hashing engine to start hashing another set of innocent bytes.
    void
    update(byte b)
    Update the hash using a single byte (8 bits).
    void
    update(int i)
    Update the hash using an integer (32 bits).
    void
    update(short s)
    Update the hash using a short integer (16 bits).
    void
    Update the hash using a string.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • W

      private final int[] W
      Work buffer for calculating the hash.
    • bytecount

      private long bytecount
    • H0

      private int H0
    • H1

      private int H1
    • H2

      private int H2
    • H3

      private int H3
    • H4

      private int H4
  • Constructor Details

    • JrpcgenSHA

      public JrpcgenSHA()
      Create a new SHA-1 hashing object.
  • Method Details

    • update

      public void update(byte b)
      Update the hash using a single byte (8 bits).
      Parameters:
      b - Byte to hash.
    • update

      public void update(short s)
      Update the hash using a short integer (16 bits).
      Parameters:
      s - Short integer to hash.
    • update

      public void update(int i)
      Update the hash using an integer (32 bits).
      Parameters:
      i - Integer to hash.
    • update

      public void update(String s)
      Update the hash using a string.
      Parameters:
      s - String to hash.
    • reset

      public void reset()
      Reset the hashing engine to start hashing another set of innocent bytes.
    • getDigest

      public byte[] getDigest()
      Retrieve the digest (that is, informally spoken, the "hash value").
      Returns:
      digest as a series of 20 bytes (80 bits).
    • getHash

      public long getHash()
      Return first 64 bits of hash digest for use as a serialization UID, etc.
      Returns:
      hash digest with only 64 bit size.
    • process

      private void process()
      Process a single block. This is pretty much copied verbatim from "Federal Information Processing Standards Publication 180-1: Specifications for the Secure Hash Standard. April 17, 1995.", pp. 9, 10.