Main Page | Packages | Class Tree | Index | Help

xp.util

class MD5

Object
  |
  +--xp.util.MD5


class MD5
extends Object

Port of the Javascript implementation of MD5 by Paul Johnston(used by Yahoo for all non-SSL logins)

Usage:

Simple usage: hexadecimal encoded MD5 hash MD5.hash("input string");

Usually you'll want to get the result in hexadecimal, so it can be submitted as part of a form without worrying about URL encoding.
hash = MD5.hash("input string",MD5.HEX);
You can also get the result in base-64 encoding
hash = MD5.hash("input string",MD5.B64);

In many uses of hashes you end up wanting to combine a key with some data.
It isn't so bad to do this by simple concatonation, but HMAC is a carefully designed method, known to be very secure.
The usage is:

hash = MD5.hmac("key", "data");
You can also get the result as a binary string

This representation is useful when you want to feed the result of a hash operation back into another operation.
The ability to do this lets you create a variety of cryptographic protocols.

For example, to do a double hash:

double_hash = MD5.hash(MD5.hash(data,MD5.STR));


Author:
ProWin Computers Ltd. - Rob Edgar

Version:
3.0.0.000

See also:
support@epresenterplus.com Original Copyright Message
A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
Digest Algorithm, as defined in RFC 1321.
Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
Distributed under the BSD License
See http://pajhome.org.uk/crypt/md5 for more info.


Field Summary

public static
B64: String
constant for base-64 encoding

public static
b64pad
base-64 pad character. "=" for strict RFC compliance

public static
chrsz
bits per input character. 8 - ASCII; 16 - Unicode

public static
HEX: String
constant for hex encoding

public static
hexcase
hex output format. 0 - lowercase; 1 - uppercase

public static
STR: String
constant for binary string

Method Summary

public static
hash ( s, encoding )
Converts a string and return a hex encoded MD5 hash

public static
hmac ( key, data, encoding )
Converts a string and return a HMAC: Keyed-Hashing for Message Authentication

public static
md5_vm_test ( )
Perform a simple self-test to see if the VM is working



Field Documentation

B64

public static var B64: String
constant for base-64 encoding

b64pad

public static var b64pad
base-64 pad character. "=" for strict RFC compliance

chrsz

public static var chrsz
bits per input character. 8 - ASCII; 16 - Unicode

HEX

public static var HEX: String
constant for hex encoding

hexcase

public static var hexcase
hex output format. 0 - lowercase; 1 - uppercase

STR

public static var STR: String
constant for binary string


Method Documentation

hash

public static function hash(s,
 encoding)
Converts a string and return a hex encoded MD5 hash

Parameters:
s
String to convert
encoding
Encoding required hex,b64,str. Defaults to hex if not supplied
Returns:
hex encoded MD5 hash

hmac

public static function hmac(key,
 data,
 encoding)
Converts a string and return a HMAC: Keyed-Hashing for Message Authentication

Parameters:
key
String to convert
data
String to convert
encoding
Encoding required hex,b64,str. Defaults to hex if not supplied
Returns:
hex encoded MD5 HMAC

md5_vm_test

public static function md5_vm_test()
Perform a simple self-test to see if the VM is working


The documentation was generated from the following file:


Generated on 10/30/2005 9:34:02 PM by AS2Doc