Created
July 25, 2012 03:18
-
-
Save noahmiller/3174168 to your computer and use it in GitHub Desktop.
StringEncryptionTransformer class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface StringEncryptionTransformer : EncryptionTransformer | |
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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