Re: base64
Re: base64
- Subject: Re: base64
- From: Kyle Hammond <email@hidden>
- Date: Tue, 10 Feb 2004 14:43:56 -0600
Once you have my Base64 code, try this:
(warning: coded in Mail.app so it may not work)
#import "GSNSDataExtensions.h"
+ (NSString *)encode:(NSString *)string
{
NSData *dataObj = [ string dataWithEncoding:NSUTF8StringEncoding ];
// Use UTF-8 encoding here, since we don't know what the incoming
string may contain.
return [ dataObj base64EncodingWithLineLength:64 ];
}
+ (NSString *)decode:(NSString *)string
{
NSData *dataObj = [ NSData dataWithBase64EncodedString:string ];
NSString *result = [ [ NSString alloc ] initWith
Data:dataObj
encoding:NSASCIIStringEncoding ];
// Can use ASCII string encoding here because Base64 is all ASCII data.
return [ result autorelease ];
}
Enjoy,
Kyle
On Feb 10, 2004, at 1:21 PM, Sascha Kuehn wrote:
i know your code but how don't how to use is.
i need this to methods.
+ (NSString *) encode: (NSString *) string ;
+ (NSString *) decode: (NSString *) string ;
sascha
On 10. Feb 2004, at 19:19 Uhr, Kyle Hammond wrote:
Hi,
Check out my Base64 Cocoa code at
<http://www.cpinternet.com/~em002400/CocoaProgramming.html>
Kyle
On Feb 10, 2004, at 11:54 AM, Sascha Kuehn <email@hidden>
wrote:
i'm not too familiar with cocoa and obj-c yet.
can someone please write me two methods to en- / decode a string with
base64?
something like this:
+ (NSString *) encode: (NSString *) string ;
+ (NSString *) decode: (NSString *) string ;
this would be very nice of you.
sascha
---------------------
Kyle Hammond
email@hidden
<http://www.snowmintcs.com/> - personal productivity software
<http://www.codeblazer.com/> - multimedia software solutions
---------------------
Kyle Hammond
email@hidden
<
http://www.snowmintcs.com/> - personal productivity software
<
http://www.codeblazer.com/> - multimedia software solutions
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
References: | |
| >Re: base64 (From: Kyle Hammond <email@hidden>) |
| >Re: base64 (From: Sascha Kuehn <email@hidden>) |