Notes
References
class Encryption {
...
/**
* Decrypt AES encrypted data by Android
*
* @param $sStr
* @param $sKey
* @return bool|string
*/
public static function decryptAesAndroid($sStr, $sKey) {
// Replace strings escaped by Android's Base64.URL_SAFE
// https://developer.android.com/reference/android/util/Base64.html#URL_SAFE
$sStr = str_replace(array('-', '_'), array('+', '/'), $sStr);
// Borrowed from https://github.com/stevenholder/PHP-Java-AES-Encrypt
$decrypted= mcrypt_decrypt(
MCRYPT_RIJNDAEL_128,
$sKey,
base64_decode($sStr),
MCRYPT_MODE_ECB
);
$dec_s = strlen($decrypted);
$padding = ord($decrypted[$dec_s-1]);
$decrypted = substr($decrypted, 0, -$padding);
return $decrypted;
}
}