forked from arqbackup/arq_restore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBlobKey.m
53 lines (45 loc) · 1.21 KB
/
BlobKey.m
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
//
// BlobKey.m
// Arq
//
// Created by Stefan Reitshamer on 6/27/11.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import "BlobKey.h"
@implementation BlobKey
- (id)initWithSHA1:(NSString *)theSHA1 stretchEncryptionKey:(BOOL)isStretchedKey {
if (self = [super init]) {
sha1 = [theSHA1 retain];
stretchEncryptionKey = isStretchedKey;
}
return self;
}
- (void)dealloc {
[sha1 release];
[super dealloc];
}
- (NSString *)sha1 {
return sha1;
}
- (BOOL)stretchEncryptionKey {
return stretchEncryptionKey;
}
#pragma mark NSCopying
- (id)copyWithZone:(NSZone *)zone {
return [[BlobKey alloc] initWithSHA1:sha1 stretchEncryptionKey:stretchEncryptionKey];
}
#pragma mark NSObject
- (NSString *)description {
return [NSString stringWithFormat:@"<BlobKey %@,stretchedkey=%@>", sha1, (stretchEncryptionKey ? @"YES" : @"NO")];
}
- (BOOL)isEqual:(id)anObject {
if (![anObject isKindOfClass:[BlobKey class]]) {
return NO;
}
BlobKey *other = (BlobKey *)anObject;
return [[other sha1] isEqualToString:sha1] && [other stretchEncryptionKey] == stretchEncryptionKey;
}
- (NSUInteger)hash {
return [sha1 hash] + (stretchEncryptionKey ? 1 : 0);
}
@end