Skip to content

Instantly share code, notes, and snippets.

@noahmiller
Created July 25, 2012 03:18
Show Gist options
  • Save noahmiller/3174168 to your computer and use it in GitHub Desktop.
Save noahmiller/3174168 to your computer and use it in GitHub Desktop.
StringEncryptionTransformer class
@interface StringEncryptionTransformer : EncryptionTransformer
{}
@implementation StringEncryptionTransformer
+ (Class)transformedValueClass
{
return [NSString class];
}
- (id)transformedValue:(NSString*)string
{
NSData* data = [string dataUsingEncoding:NSUTF8StringEncoding];
return [super transformedValue:data];
}
- (id)reverseTransformedValue:(NSData*)data
{
if (nil == data)
{
return nil;
}
data = [super reverseTransformedValue:data];
return [[[NSString alloc] initWithBytes:[data bytes]
length:[data length]
encoding:NSUTF8StringEncoding]
autorelease];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment