@@ -8,13 +8,16 @@ * Q Public License 1.0, which can be found in the file LICENSE included in * the packaging of this file. */ #import "OFObject.h" +#import "OFString.h" #define MD5_DIGEST_SIZE 16 #define SHA1_DIGEST_SIZE 20 + +extern int _OFHashing_reference; /** * The OFMD5Hash class provides functions to create an MD5 hash. */ @interface OFMD5Hash: OFObject @@ -44,11 +47,11 @@ /** * \return A buffer containing the hash (MD5_DIGEST_SIZE = 16 bytes). * The buffer is part of object's memory pool. */ -- (char*)digest; +- (uint8_t*)digest; @end /** * The OFSHA1Hash class provides functions to create an SHA1 hash. */ @@ -55,11 +58,11 @@ @interface OFSHA1Hash: OFObject { uint32_t state[5]; uint64_t count; char buffer[64]; - char digest[SHA1_DIGEST_SIZE]; + uint8_t digest[SHA1_DIGEST_SIZE]; BOOL calculated; } /** @@ -80,7 +83,22 @@ /** * \return A buffer containing the hash (SHA1_DIGEST_SIZE = 20 bytes). * The buffer is part of object's memory pool. */ -- (char*)digest; +- (uint8_t*)digest; +@end + +/** + * The OFHashing category provides methods to calculate hashes for strings. + */ +@interface OFString (OFHashing) +/** + * \return The MD5 hash of the string as an autoreleased OFString + */ +- (OFString*)md5Hash; + +/** + * \return The SHA1 hash of the string as an autoreleased OFString + */ +- (OFString*)sha1Hash; @end