Привет, ребята,
Here I am having a problem In encoding/decoding the strings.
Actually I had a string which I am encoding it using the base64.which was working fine.
And now I need to decode the string that was encoded before and want to print it.
I code I written as:
I imported the base64.h and base64.m files into my application which contains the methods as:
+ (NSData *) dataWithBase64EncodedString:(NSString *) string;
- (id) initWithBase64EncodedString:(NSString *) string;
- (NSString *) base64EncodingWithLineLength:(unsigned int) lineLength;
And the code in my view controller where I encode the String is:
- (id)init {
if (self = [super init]) {
// Custom initialization
userName = @"Sekhar";
password = @"Bethalam";
}
return self;
}
-(void)reloadView
{
NSString *authStr = [NSString stringWithFormat:@"%@:%@",userName,password];
NSData *authData = [authStr dataUsingEncoding:NSASCIIStringEncoding];
NSString *authValue = [NSString stringWithFormat:@"%@", [authData base64EncodingWithLineLength:30]];
NSLog(authValue);
//const char *str = authValue;
//NSString *decStr = [StringEncryption DecryptString:authValue];
//NSLog(decStr);
//NSData *decodeData = [NSData decode:authValue];
//NSString *decStr = [NSString stringWithFormat:@"%@",decodeData];
//NSStr
//NSLog(decStr);
}
-(void)viewWillAppear:(BOOL)animated
{
[self reloadView];
}
и теперь я хочу декодировать строку, которую я закодировал.
Но я не знаю, как это сделать. Кто-нибудь может подсказать мне, как его получить.
Любая помощь будет высоко ценится.
Спасибо,
Мониш.