.. title:: dojo.crypto.MD5 -- The Dojo Manual

.. this is a comment. for more information on reST, see:
   http://docutils.sf.net/docs/user/rst/quickstart.html
   http://docutils.sf.net/docs/user/rst/quickref.html

Name
===============================================================================

dojo.crypto.MD5 - MD5 Message Digest encryption implementation

Summary and Overview
===============================================================================

This is an implementation of the MD5 message digest algorithm, based entirely on
the Javascript implementation by Paul Johnstone
(http://pajhome.org.uk/crypt/md5/index.html).  Please see LICENSING for license
details.

The class is completely self-contained, and includes methods for HMAC digest
authentication.

Usage
===============================================================================

::

    var b64hash = dojo.crypto.MD5.compute(
        "The rain in Spain falls mainly on the plain", 
        dojo.crypto.MD5.outputTypes.Base64
    );
    var hexHash = dojo.crypto.MD5.compute(
        "The rain in Spain falls mainly on the plain", 
        dojo.crypto.MD5.outputTypes.Hex
    );
    var b64hmac = dojo.crypto.MD5.getHMAC(
        "The rain in Spain falls mainly on the plain",
        "foobar"
    );
    var hexhmac = dojo.crypto.MD5.getHMAC(
        "The rain in Spain falls mainly on the plain", 
        "foobar",
        dojo.crypto.MD5.outputTypes.Hex
    );

API Reference
===============================================================================


Properties
---------------------------------------

``outputTypes``:

    An enumeration (object) for use in determining output types.  Valid values
    are "Base64", "Hex", and "String", i.e. dojo.crypto.MD.outputTypes.Base64.


Methods
---------------------------------------

``compute(data, outputType)``:

    Computes a message digest according to the spec for MD5.

    ``data``:
        A string of data to create the digest from.

    ``outputType``:
        An integer representing the type of output (see outputTypes, above).
        Optional, defaults to dojo.crypto.MD5.outputTypes.Base64.

    *return*:
        A string encoded according to the passed outputType.
	
``getHMAC(data, key, outputType)``:

    Computes an HMAC message digest for authentication purposes.

    ``data``:
        A string of data to create the digest from.

    ``key``:
        A string representing the key with which to create the digest.

    ``outputType``:
        An integer representing the type of output (see outputTypes, above).
        Optional, defaults to dojo.crypto.MD5.outputTypes.Base64.

    *return*:
        A string encoded according to the passed outputType.
	

Requires
===============================================================================

No requirements.

Provides
===============================================================================

dojo.crypto.MD5
    Singleton pattern object to perform MD5 digest computations.


To Do
===============================================================================

Nothing.

About
===============================================================================

:Author: Thomas R. Trenka, Ph.D.
:Version: 0.2
:Copyright: Dojo Foundation, 200x
:Date: 2005/12/12

.. vim:ts=4:et:tw=80:shiftwidth=4:
