- Inherits from:
- Object
- Declared in:
- DMD5.h
Object
|
+---DMD5
Class Description
The DMD5 class implements a number of methods for using the RSA's MD5 message
algorithmes.
- Example:
#include <stdio.h>
#include "ofc/DMD5.h"
int main(int argc, char *argv[])
{
DMD5 *md1 = [DMD5 alloc];
DMD5 *md2 = [DMD5 new ];
DText *str;
DData *data;
[md1 init :"This is a test string for MD5"]; // Init with a c-string
str = [md1 hexdigest]; // Convert MD5 value of string to hex
printf("MD5 digest in hex of \"This is a test string for MD5\":%s.\n", [str cstring]);
[str free];
[md2 update :"abcdefghijklmnopqrstuvwxyz"]; // Update the md2 with a c-string and ..
[md2 update :"0123456789" :10]; // .. data string
data = [md2 digest]; // Convert MD5 result to data string
str = [data toBase64]; // Convert data string to base64
printf("MD5 (in base64) of \"abcdefghijklmnopqrstuvwxyz0123456789\":%s.\n", [str cstring]);
[str free];
[data free];
[md1 free]; // Cleanup
[md2 free];
return 0;
}
- Last modified:
- 02-Aug-2008 (DMD5.h)
Instance Variables
- private MD5_CTX _md5
- the md5 context
- Constructors
- - (DMD5 *) init
- Initialise to an empty object
- Returns:
- the instance
- - (DMD5 *) init :(const char *) cstring
- Initialise the object with a c-string
- Parameters:
- cstring - the string
- Returns:
- the object
- - (DMD5 *) init :(const unsigned char *) data :(unsigned long) length
- Initialise the object with data
- Parameters:
- data - the data ('\0' allowed)
length - the length of the data
- Returns:
- the object
- Copy related methods
- - shallowCopy
- Do a shallow copy of the object (not implemented)
- Update methods
- - (DMD5 *) update :(const char *) cstring
- Update the object with a c-string. Repeated calls can be compared
to a single call in which the strings are concatted
- Parameters:
- cstring - the c-string to be feeded to md5
- Returns:
- the object
- - (DMD5 *) update :(const unsigned char *) data :(unsigned long) length
- Update the object with data. Repeated calls can be compared
to a single call in which the strings are concatted
- Parameters:
- data - the data to be feeded to md5
length - the length of the data
- Returns:
- the object
- Digest methods
- - (DData *) digest
- Returns the (current) digest of all data passed to the object.
- Returns:
- the (new) data string object with the digest
- - (DText *) hexdigest
- Return the (current) digest of all data passed to the object. The
returning string contains the digest in hexadecimal ascii characters.
- Returns:
- the (new) string object with the digest
generated 06-Sep-2008 by ObjcDoc 3.0.0