- Inherits from:
- Object
- Declared in:
- DSHA1.h
Object
|
+---DSHA1
Class Description
The DSHA1 class implements a number of methods for using the NIST's SHA
algorithm. The code is based on 'SHA-1 in C' by Steve Reid (steve[at]edmweb.com)
which is in Public Domain.
- Example:
#include <stdio.h>
#include "ofc/DSHA1.h"
int main(int argc, char *argv[])
{
DSHA1 *sha1 = [DSHA1 alloc];
DSHA1 *sha2 = [DSHA1 new ];
DText *str;
int i;
[sha1 init :"Test string for the SHA1 class"]; // Init with c-string
str = [sha1 hexdigest]; // Convert to string and print
printf("SHA1 for the test string:%s.\n", [str cstring]);
[str free];
for (i = 0; i < 10; i++)
{
[sha2 update :"abcdefghijklmnopqrstuvwxyz"]; // Repeated adding strings to sha
}
str = [sha2 hexdigest]; // Convert to string and print
printf("SHA1 for the repeated test string:%s.\n", [str cstring]);
[str free];
[sha1 free]; // Cleanup
[sha2 free];
return 0;
}
- Last modified:
- 28-Jul-2008 (DSHA1.h)
Instance Variables
- private uint32_t _state[5]
- private uint32_t _count[2]
- private unsigned char _buffer[64]
- Constructors
- - (DSHA1 *) init
- Initialise the sha object
- Returns:
- the object
- - (DSHA1 *) init :(const char *) cstring
- Initialise the sha object with a string
- Parameters:
- cstring - the c-string
- Returns:
- the object
- - (DSHA1 *) init :(const unsigned char *) data :(unsigned long) length
- Initialise the sha object with data
- Parameters:
- data - the data ('\0' allowed)
length - the length of the data
- Returns:
- the object
- Update methods
- - (DSHA1 *) 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 sha1
- Returns:
- the object
- - (DSHA1 *) 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 sha
length - the length of the data
- Returns:
- the object
- Digest methods
- - (DData *) digest
- Return the (current) digest of all data passed to the object.
- Returns:
- the (new) data string object with the digest
- - (DText *) hexdigest
- Returns 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