I have a PHP class to encrypt and decrypt strings:
$ralphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,.:;?~@#\$%^&*()_+-=][}{><";
$alphabet = $ralphabet . $ralphabet;
function encrypt ($password,$strtoencrypt) {
global $ralphabet;
global $alphabet;
for( $i=0; $i<strlen($password); $i++ )
{
$cur_pswd_ltr = substr($password,$i,1);
$pos_alpha_ary[] = substr(strstr($alphabet,$cur_pswd_ltr),0,strlen($ralphabet));
}
$i=0;
$n = 0;
$nn = strlen($password);
$c = strlen($strtoencrypt);
$encrypted_string = "";
while($i<$c)
{
$encrypted_string .= substr($pos_alpha_ary[$n],strpos($ralphabet,substr($strtoencrypt,$i,1)),1);
$n++;
if($n==$nn) $n = 0;
$i++;
}
return $encrypted_string;
}
It receives the string to encrypt, and a KEY.
I need to translate it to objective-C, but I don't understand PHP much.
What are the equivalents to the functions that are used in the PHP class, so that I can create the class in objective-C?