-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathD2PTextureHash.m
More file actions
74 lines (50 loc) · 1.17 KB
/
D2PTextureHash.m
File metadata and controls
74 lines (50 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//
// D2PTextureHash.m
// D2Patch
//
// Created by Andrey on 23/02/2017.
//
#import "D2PTextureHash.h"
#import <CommonCrypto/CommonDigest.h>
@implementation D2PTextureHash
- (instancetype) initWithData:(const void *)data length:(NSUInteger)length
{
unsigned char result[CC_MD5_DIGEST_LENGTH];
CC_MD5(data, length, result);
NSData *value = [NSData dataWithBytes:result length:CC_MD5_DIGEST_LENGTH];
return [self initWithPlainValue:value];
}
- (instancetype) initWithPlainValue:(NSData *)value
{
self = [super init];
if (self)
{
_data = value;
}
return self;
}
- (BOOL) isEqual:(id)object
{
if ([object isMemberOfClass:[D2PTextureHash class]])
{
D2PTextureHash *otherHash = (D2PTextureHash *)object;
return [_data isEqualToData:otherHash->_data];
}
else
{
return NO;
}
}
- (NSUInteger) hash
{
return _data.hash;
}
- (instancetype) copyWithZone:(NSZone *)zone
{
return [[D2PTextureHash alloc] initWithPlainValue:_data];
}
- (NSString *) description
{
return [NSString stringWithFormat:@"<%@ = %@>", NSStringFromClass(self.class), _data];
}
@end