Skip to content

Instantly share code, notes, and snippets.

@cruffenach
Created October 9, 2011 20:42
Show Gist options
  • Save cruffenach/1274142 to your computer and use it in GitHub Desktop.
Save cruffenach/1274142 to your computer and use it in GitHub Desktop.
An NSString subclass main for use with encrypted strings. For an article at www.iCodeBlog.com
#import "MaaSEncryptedString.h"
#import "NSString+Helper.h"
@implementation MaaSEncryptedString
+(NSString*)encryptedString:(NSString*)string {
return [[NSString stringWithFormat:@"%@", [string SHA1]];
}
+(id)encryptedStringWithString:(NSString *)string {
return [[[MaaSEncryptedString alloc] initWithString:string] autorelease];
}
-(id)initWithString:(NSString*)string {
if(self = [self init]) {
_backingStore = [[MaaSEncryptedString encryptedString:string] copy];
}
return self;
}
-(void)dealloc {
[_backingStore release];
[super dealloc];
}
-(NSUInteger)length {
return [_backingStore length];
}
-(unichar)characterAtIndex:(NSUInteger)index {
return [_backingStore characterAtIndex:index];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment