In php this line
for($i = 0; $i < strlen($string); $i++){
$keychar = substr($key, ($i % strlen($key))-1,1);
echo $keychar;
}
returns `70684292517 `
And if i make the equivalent of this in objective-c it returns a whole different value.
for (int i = 0; i < string.length; i++) {
NSString *_keychar = [key substringWithRange:NSMakeRange((i % key.length)-1,1)];
//The fix
NSString *_keychar = [key substringWithRange:NSMakeRange(((i % key.length) ? (i % key.length) : (key.length) )-1,1)];
NSLog(@"%@",_keychar);
}
returns `068429251`
So, why isn't the obj-c code returning the same value as the php one(how it should be)? What am i doing wrong? string has a length of 11 and the key has a value of 0684292517
FIXED