0

I'm trying to use function that decrypt for me ciphertext after encrypted using Objective-C

I know that the problem is in padding.

so I found this function form this site.

http://tharindufit.wordpress.com/2011/12/15/aes128-encryption-in-ios-and-decryption-in-php/#comment-470

thanx for the guy posted.

function decrypt_password($pass,$key)
{

    $base64encoded_ciphertext = $pass;

    $res_non = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, base64_decode($base64encoded_ciphertext), ‘ecb’);

    $decrypted = $res_non;
    $dec_s2 = strlen($decrypted);

    $padding = ord($decrypted[$dec_s2-1]);
    $decrypted = substr($decrypted, 0, -$padding);

    return  $decrypted;
}

The result I found is this:

Notice: Use of undefined constant ‘ecb’ - assumed '‘ecb’' in C:\wamp\www\enc3.php on line 7

Warning: mcrypt_decrypt() [function.mcrypt-decrypt]: Module initialization failed in C:\wamp\www\enc3.php on line 7

Can any one help to make the code work greatly since i need it with same result to use it in decrypt the recived ciphertext from Objective-C?

by the way I use wamp server 2.0 that support mcrypt function.

Chirag Kothiya
  • 955
  • 5
  • 12
  • 28
user1584540
  • 21
  • 1
  • 1
  • 5

1 Answers1

0

Fix your keyboard. You wrote a while you should have used a '. I'm sure they look very similar but one of them works and the other one doesn't.

‘ecb‘ won't work. It's 'ecb'

Tom van der Woerdt
  • 29,532
  • 7
  • 72
  • 105
  • Thanx dude. I use it , The error is gone , but I didn't got any result. I use this code to test it $passValue = "Iphone 5"; $keyValue = "0000"; $var = decrypt_password($passValue,$keyValue); echo $var; – user1584540 Aug 08 '12 at 11:47