WARNING: Most of this content (with the exception of the Mozilla 1.9 XPCOM reference) is very old, and can be expected to be out of date and possibly obsolete. For better XUL documentation, please visit the XUL hub at the Mozilla Developer Center.

nsICryptoHash

IID:1e5b7c43-4688-45ce-92e1-77ed931e3bbe
Inherits From:nsISupports

This interface provides crytographic hashing algorithms.

This interface is implemented by the following components:


Constants

Hashing Algorithms. These values are to be used by the init method to indicate which hashing function to use. These values map directly onto the values defined in mozilla/security/nss/lib/cryptohi/hasht.h.
PRInt16 MD2 = 1
PRInt16 MD5 = 2
PRInt16 SHA1 = 3
PRInt16 SHA256 = 4
PRInt16 SHA384 = 5
PRInt16 SHA512 = 6

Methods

ACString finish ( PRBool ASCII ) void init ( PRUint32 algorithm ) void initWithString ( ACString algorithm ) void update ( arrayof PRUint8 data , PRUint32 len ) void updateFromStream ( nsIInputStream stream , PRUint32 len )

ACString finish ( PRBool ASCII )

Completes this hash object and produces the actual hash data.

NOTE: This method may be called any time after init is called. This call resets the object to its pre-init state.

Arguments:
ASCII: if true then the returned value is a base-64 encoded string. if false, then the returned value is binary data.
Returns:
a hash of the data that was read by this object. This can be either binary data or base 64 encoded.

void init ( PRUint32 algorithm )

Initialize the hashing object. This method may be called multiple times with different algorithm types.

NOTE: This method or initWithString must be called before any other method on this interface is called.

Arguments:
algorithm: the algorithm type to be used. This value must be one of the above valid algorithm types.

void initWithString ( ACString algorithm )

Initialize the hashing object. This method may be called multiple times with different algorithm types.

NOTE: This method or init must be called before any other method on this interface is called.

Arguments:
algorithm: the algorithm type to be used.

void update ( arrayof PRUint8 data , PRUint32 len )

Arguments:
data: a buffer to calculate the hash over
len: the length of the buffer |data|

void updateFromStream ( nsIInputStream stream , PRUint32 len )

Calculates and updates a new hash based on a given data stream.

Arguments:
stream: an input stream to read from.
len: how much to read from the given |stream|. Passing PR_UINT32_MAX indicates that all data available will be used to update the hash.

Reference documentation is generated from Mozilla's source.

Copyright © 1999-2006 XULPlanet.com