MYDigest Class Reference

Abstract superclass for cryptographic digests (aka hashes). More...

Inherited by MYSHA1Digest, and MYSHA256Digest.

List of all members.

Public Member Functions

(id) - initWithRawDigest:length:
 Initializes a MYDigest from an existing raw digest.
(NSComparisonResult) - compare:
 Byte-by-byte lexical comparison of digest data.

Static Public Member Functions

(id) + digestFromDigestData:
 Wraps an existing digest, stored in an NSData object, in a MYDigest object.
(id) + digestFromHexString:
 Wraps an existing digest, expressed as a hex string, in a MYDigest object.
(id) + digestOfData:
 Computes a cryptographic digest of the given data.
(id) + digestOfBytes:length:
 Computes a cryptographic digest of the given data.
(uint32_t) + algorithm
 The algorithm used by this subclass.
(size_t) + length
 The length of digests created by this subclass.
(void) + computeDigest:ofBytes:length:
 Primitive digest generation method.

Properties

NSData * asData
 Returns the digest as an NSData object.
NSString * hexString
 Returns the digest as a hex string.
NSString * abbreviatedHexString
 Returns the first 8 digits (32 bits) of the digest's hex string, followed by "...".
uint32_t algorithm
 The algorithm that created this digest.
size_t length
 The length (in bytes, not bits!) of this digest.
const void * bytes
 A pointer to the raw bytes of digest data.

Detailed Description

Abstract superclass for cryptographic digests (aka hashes).

Each specific type of digest has its own concrete subclass. Digests are full-fledged value objects, and can be compared, used as dictionary keys, copied, and archived.


Member Function Documentation

+ (uint32_t) algorithm  

The algorithm used by this subclass.

(Abstract method.) For interpreting the results, see the comment on the instance method of the same name.

- (NSComparisonResult) compare: (MYDigest*)  other  

Byte-by-byte lexical comparison of digest data.

+ (void) computeDigest: (void*)  dstDigest
ofBytes: (const void*)  bytes
length: (size_t)  length 

Primitive digest generation method.

(Abstract.)

+ (id) digestFromDigestData: (NSData*)  digestData  

Wraps an existing digest, stored in an NSData object, in a MYDigest object.

+ (id) digestFromHexString: (NSString*)  hexString  

Wraps an existing digest, expressed as a hex string, in a MYDigest object.

If the string is invalid (wrong length, or not hexadecimal), returns nil.

+ (id) digestOfBytes: (const void*)  bytes
length: (size_t)  length 

Computes a cryptographic digest of the given data.

+ (id) digestOfData: (NSData*)  data  

Computes a cryptographic digest of the given data.

- (id) initWithRawDigest: (const void*)  rawDigest
length: (size_t)  length 

Initializes a MYDigest from an existing raw digest.

MYDigest itself is abstract, so this must be called on a subclass instance.

+ (size_t) length  

The length of digests created by this subclass.

(Abstract method.)


Property Documentation

- (NSString *) abbreviatedHexString [read, assign]

Returns the first 8 digits (32 bits) of the digest's hex string, followed by "...".

This is intended only for use in log messages or object descriptions, since 32 bits isn't nearly enough to provide any useful uniqueness.

- (uint32_t) algorithm [read, assign]

The algorithm that created this digest.

There is no universal way to name these, so on Mac OS values are interpreted as CSSM_ALGORITHMS; on iOS, as CCHmacAlgorithm. (Abstract method.)

- (NSData *) asData [read, assign]

Returns the digest as an NSData object.

- (const void *) bytes [read, assign]

A pointer to the raw bytes of digest data.

- (NSString *) hexString [read, assign]

Returns the digest as a hex string.

- (size_t) length [read, assign]

The length (in bytes, not bits!) of this digest.


The documentation for this class was generated from the following files:
Generated on Sun Apr 17 12:23:58 2011 for MYCrypto by  doxygen 1.6.3