jsdsi
Class Hash

java.lang.Object
  extended byjsdsi.Obj
      extended byjsdsi.Hash
All Implemented Interfaces:
java.io.Serializable

public class Hash
extends Obj

A cryptographic hash.

Version:
$Revision: 1.9.2.1 $ $Date: 2005/11/08 03:12:52 $
Author:
Sameer Ajmani, Sean Radford
See Also:
Serialized Form

Field Summary
 
Fields inherited from class jsdsi.Obj
_obj
 
Constructor Summary
Hash(DigestAlgoEnum a, byte[] d, java.net.URI[] u)
          Creates a new Hash.
Hash(DigestAlgoEnum a, Obj o, java.net.URI[] u)
          Creates a new Hash.
Hash(java.lang.String a, byte[] d)
          Deprecated. use Hash(jsdsi.util.DigestAlgoEnum, byte[], java.net.URI[])
Hash(java.lang.String a, byte[] d, java.net.URI[] u)
          Deprecated. use Hash(jsdsi.util.DigestAlgoEnum, byte[], URI[])
Hash(java.lang.String a, Obj o)
          Deprecated. use Hash(jsdsi.util.DigestAlgoEnum, jsdsi.Obj, java.net.URI[])
Hash(java.lang.String a, Obj o, java.net.URI[] u)
          Deprecated. use Hash(jsdsi.util.DigestAlgoEnum, Obj, URI[])
 
Method Summary
static Hash create(DigestAlgoEnum a, byte[] d, java.net.URI[] u)
          Creates a new Hash using a given algorithm name, a value to hash, and an array of URIs.
static Hash create(DigestAlgoEnum a, java.io.InputStream is, java.net.URI[] u)
          Creates a new Hash of the data from the given InputStream, using the given algorithm
static Hash create(java.lang.String a, byte[] d, java.net.URI[] u)
          Deprecated. use create(jsdsi.util.DigestAlgoEnum, byte[], java.net.URI[])
static Hash create(java.lang.String a, java.io.InputStream is, java.net.URI[] u)
          Deprecated. use create(jsdsi.util.DigestAlgoEnum, java.io.InputStream, java.net.URI[])
 boolean equals(java.lang.Object o)
           
 java.lang.String getAlgorithm()
           
 byte[] getData()
           
 DigestAlgoEnum getDigest()
           
 java.net.URI[] getURIs()
           
 int hashCode()
           
static Hash parseHash(SexpList l)
           
 SexpList toSexp()
          Creates an SexpList -representation from this SDSI-object.
 
Methods inherited from class jsdsi.Obj
parseObj, parseObj, readResolve, toByteArray, toString, toString, toTransport
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Hash

public Hash(DigestAlgoEnum a,
            byte[] d,
            java.net.URI[] u)
Creates a new Hash.

Parameters:
a - hash algorithm
d - hash value (not the data to hash)
u - URIs of the hashed data (may be null).

Hash

public Hash(DigestAlgoEnum a,
            Obj o,
            java.net.URI[] u)
Creates a new Hash.

Parameters:
a - hash algorithm.
o - JSDSI object to hash.
u - URIs of the hashed data (may be null).

Hash

public Hash(java.lang.String a,
            byte[] d,
            java.net.URI[] u)
Deprecated. use Hash(jsdsi.util.DigestAlgoEnum, byte[], URI[])

Creates a new Hash.

Parameters:
a - SPKI hash algorithm name
d - hash value (not the data to hash)
u - URIs of the hashed data

Hash

public Hash(java.lang.String a,
            Obj o,
            java.net.URI[] u)
Deprecated. use Hash(jsdsi.util.DigestAlgoEnum, Obj, URI[])

Creates a new Hash.

Parameters:
a - hash algorithm name.
o - object to hash.
u - URIs of the hashed data.

Hash

public Hash(java.lang.String a,
            byte[] d)
Deprecated. use Hash(jsdsi.util.DigestAlgoEnum, byte[], java.net.URI[])

Creates a new Hash from an algorithm name and a byte array that contains a hash value.

Parameters:
a - name of the hash algorithm used.
d - the value of the hash (not the data to hash).

Hash

public Hash(java.lang.String a,
            Obj o)
Deprecated. use Hash(jsdsi.util.DigestAlgoEnum, jsdsi.Obj, java.net.URI[])

Creates a new Hash from an algorithm name and an object.

Parameters:
a - name of the hash algorithm used.
o - JSDSI object to calculate the hash value from.
Method Detail

create

public static Hash create(DigestAlgoEnum a,
                          byte[] d,
                          java.net.URI[] u)
Creates a new Hash using a given algorithm name, a value to hash, and an array of URIs.

Parameters:
a - hash algorithm
d - data to hash
u - URIs of the data to hash
Returns:
the created Hash object (may be null)

create

public static Hash create(DigestAlgoEnum a,
                          java.io.InputStream is,
                          java.net.URI[] u)
Creates a new Hash of the data from the given InputStream, using the given algorithm

Parameters:
a - hash algorithm
is - data to hash
u - URIs of the data being hashed (may be null)
Returns:
the created Hash object

create

public static Hash create(java.lang.String a,
                          byte[] d,
                          java.net.URI[] u)
                   throws java.security.NoSuchAlgorithmException
Deprecated. use create(jsdsi.util.DigestAlgoEnum, byte[], java.net.URI[])

Creates a new Hash using a given algorithm name, a value to hash, and an array of URIs.

Parameters:
a - hash algorithm name
d - data to hash
u - URIs of the data to hash
Returns:
the created Hash object
Throws:
java.security.NoSuchAlgorithmException

create

public static Hash create(java.lang.String a,
                          java.io.InputStream is,
                          java.net.URI[] u)
                   throws java.security.NoSuchAlgorithmException
Deprecated. use create(jsdsi.util.DigestAlgoEnum, java.io.InputStream, java.net.URI[])

Creates a new Hash of the data from the given InputStream, using the given algorithm.

Parameters:
a - hash algorithm name
is - data to hash
u - URIs of the data being hashed
Returns:
the created Hash object
Throws:
java.security.NoSuchAlgorithmException

getDigest

public DigestAlgoEnum getDigest()
Returns:
the digest for this Hash

getAlgorithm

public java.lang.String getAlgorithm()
Returns:
the JDK name of the hash algorithm.

getData

public byte[] getData()
Returns:
the hash value.

getURIs

public java.net.URI[] getURIs()
Returns:
the URIs of the hashed data.

equals

public boolean equals(java.lang.Object o)
Specified by:
equals in class Obj
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Specified by:
hashCode in class Obj
See Also:
Object.hashCode()

toSexp

public SexpList toSexp()
Description copied from class: Obj
Creates an SexpList -representation from this SDSI-object.

Specified by:
toSexp in class Obj
Returns:
an SexpList that represents this SDSI-object.

parseHash

public static Hash parseHash(SexpList l)
                      throws SexpParseException
Throws:
SexpParseException


Copyright © 2002-2006 JSDSI. All Rights Reserved.