| Previous | Next | Frames | No Frames |
| Summary: Field | Property | Contructor | Method | Detail: Field | Property | Contructor | Method |
Object | +--xp.util.MD5
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 | |
| public static var B64: String |
| constant for base-64 encoding |
| public static var b64pad |
| base-64 pad character. "=" for strict RFC compliance |
| public static var chrsz |
| bits per input character. 8 - ASCII; 16 - Unicode |
| public static var HEX: String |
| constant for hex encoding |
| public static var hexcase |
| hex output format. 0 - lowercase; 1 - uppercase |
| public static var STR: String |
| constant for binary string |
|
| Converts a string and return a hex encoded MD5 hash | ||||||
|
|
| Converts a string and return a HMAC: Keyed-Hashing for Message Authentication | |||||||||
|
|
| Perform a simple self-test to see if the VM is working |
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));