Skip navigation links

Oracle Security Developer Tools Crypto Java API Reference
11g (11.1.1)

E10668-02


oracle.security.crypto.core
Class SHA

java.lang.Object
  extended by oracle.security.crypto.core.MessageDigest
      extended by oracle.security.crypto.core.SHA

All Implemented Interfaces:
java.lang.Cloneable

public final class SHA
extends MessageDigest

The SHA (Secure Hash Algorithm) message digest algorithms, as defined in FIPS-180-2 Secure Hash Standard. This class implements SHA-1, SHA-256, SHA-384 and SHA-512.


Nested Class Summary

 

Nested classes/interfaces inherited from class oracle.security.crypto.core.MessageDigest
MessageDigest.MDState

 

Field Summary

 

Fields inherited from class oracle.security.crypto.core.MessageDigest
algID

 

Constructor Summary
SHA()
          Empty constructor.

 

Method Summary
 java.lang.String algName()
          Returns the algorithm name of this message digest.
 int blockSize()
          Returns the block size the message digest.
 java.lang.Object clone()
          Clone this object.
 void computeCurrent()
          Completes the hash computation, performing any necessary operations such as padding.
 AlgorithmIdentifier getAlgID()
          Returns the algorithm identifier of this message digest.
 byte[] getDigestBits()
          Returns a copy of the current digest bytes.
 int getDigestLength()
          Returns the length in bytes of the message digest.
protected  MessageDigest.MDState getState()
          Gets the state of this MessageDigest instance.
 void init()
          Resets this message digest object to its initial state.
 boolean isValid()
          Returns true if this SHA is in a valid state and its digest bits are usable; otherwise returns false.
 void setAlgID(AlgorithmIdentifier algID)
          Sets the SHA algorithm to use.
protected  void setState(MessageDigest.MDState state)
          Sets the state of this MessageDigest instance.
 void update(byte aValue)
          Adds one byte to the data being digested.
 void update(byte[] input, int off, int len)
          Adds the specified sequence of bytes to the data being digested.

 

Methods inherited from class oracle.security.crypto.core.MessageDigest
computeDigest, computeDigest, getInstance, isEqual, toString, update, update, update, update, update, update, update, update, update, update, update, updateASCII

 

Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

 

Constructor Detail

SHA

public SHA()
Empty constructor. By default, a newly SHA object will implement the SHA-1 algorithm. To use another SHA algorithm, use the setAlgID method.

Method Detail

setAlgID

public void setAlgID(AlgorithmIdentifier algID)
              throws AlgorithmIdentifierException
Sets the SHA algorithm to use. The possible algorithms are SHA-1, SHA-256, SHA-384 and SHA-512.
Overrides:
setAlgID in class MessageDigest
Parameters:
algID - The AlgorithmIdentifier to use.
Throws:
AlgorithmIdentifierException
See Also:
AlgID

getAlgID

public AlgorithmIdentifier getAlgID()
Returns the algorithm identifier of this message digest.
Specified by:
getAlgID in class MessageDigest
Returns:
An AlgorithIdentifier object representing the hash algorithm of this MessageDigest instance.

algName

public java.lang.String algName()
Returns the algorithm name of this message digest.
Specified by:
algName in class MessageDigest
Returns:
"SHA"

blockSize

public int blockSize()
Returns the block size the message digest.
Specified by:
blockSize in class MessageDigest

getDigestLength

public int getDigestLength()
Returns the length in bytes of the message digest.
Specified by:
getDigestLength in class MessageDigest

init

public void init()
Resets this message digest object to its initial state.
Specified by:
init in class MessageDigest

update

public void update(byte[] input,
                   int off,
                   int len)
Adds the specified sequence of bytes to the data being digested.
Overrides:
update in class MessageDigest
Parameters:
input - the input array
off - start position in the input array
len - the number of input array elements to add to the data being digested

update

public void update(byte aValue)
Adds one byte to the data being digested.
Specified by:
update in class MessageDigest

getDigestBits

public byte[] getDigestBits()
Returns a copy of the current digest bytes.
Overrides:
getDigestBits in class MessageDigest

isValid

public boolean isValid()
Returns true if this SHA is in a valid state and its digest bits are usable; otherwise returns false.
Overrides:
isValid in class MessageDigest

computeCurrent

public void computeCurrent()
Completes the hash computation, performing any necessary operations such as padding. The final result of the hash is stored in digestBits.
Specified by:
computeCurrent in class MessageDigest

clone

public java.lang.Object clone()
Clone this object.
Specified by:
clone in class MessageDigest

getState

protected MessageDigest.MDState getState()
Description copied from class: MessageDigest
Gets the state of this MessageDigest instance.
Specified by:
getState in class MessageDigest

setState

protected void setState(MessageDigest.MDState state)
Description copied from class: MessageDigest
Sets the state of this MessageDigest instance.
Specified by:
setState in class MessageDigest

Skip navigation links

Oracle Security Developer Tools Crypto Java API Reference
11g (11.1.1)

E10668-02


Copyright © 2005, 2009, Oracle. All rights reserved.