I'm encrypting the data in ECB 256 AES using a key in the javascript and decrypting at php using the username and key. It is encrypting but i'm failing to decrypt in the php.
I'm trying to do this in ionic app.
In app.js in config:
.config(['$cryptoProvider', function($cryptoProvider){
$cryptoProvider.setCryptographyKey('ABCD1234567890EF');
}])
In controller:
var encryptedUsername = $crypto.encrypt(username);
var key = 'ABCD1234567890EF';
In php:
$username = $_POST['encryptedUsername'];
$key =$_POST['key'];
function fnDecrypt($sValue, $sSecretKey)
{
return rtrim(
mcrypt_decrypt(
MCRYPT_RIJNDAEL_256,
$sSecretKey,
base64_decode($sValue),
MCRYPT_MODE_ECB
), "\0"
);
}
$plaintext = fnDecrypt($username, $key);
echo $plaintext;
please tell me where I'm making a mistake.