Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

BASE64 decode function into Objective-C?

DT_DTDGDT_DTDG AusPosts: 2New Users Noob
edited September 2013 in Mac OS X Development
I'm moving over from PHP and getting stuck into Objective-C.
One thing I am trying to rewrite is a custom BASE64 function.

How would this be written in Obj-C?
public static function decode($string, $key=hYc87.@.l_D3d-)
{
$result = '';
$string = str_replace(' ', '+', $string);
$string = base64_decode($string);
$string = str_replace($key, '', $string);
for($i=0; $i<strlen($string); $i++) {
$char = substr($string, $i, 1);
$keychar = substr($key, ($i % strlen($key))-1, 1);
$char = chr(ord($char)-ord($keychar));
$result.=$char;
}
return $result;
}

Replies

Sign In or Register to comment.