Amaç-c kripto sınıfı PHP

0 Cevap php

Ben Encript ve decript dizeleri bir PHP sınıfı vardır:

$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 encript, and a KEY. I need to translate it to objective-c, but i don't understand PHP much... Can anyone help me with the functions that are used in the php class, so that I can create the class in obj-c?

Çok teşekkürler,

RL

0 Cevap