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?
All the functions you can find in this code come directly from the C side of PHP, doing man theFunction will give you all the informations you need about them.
30 seconds in Google led me to this, I suppose if you invest a little time you can find the docs for the rest of the functions.
精彩评论