I want to access an API with PHP. The specifications are:
- Twofish algorithm
- ECB cipher mode
- PKCS7 block padding mode
I have tried a lot of different PHP functions and libraries, but none seems to work.
Here is my code:
function encrypt($data, $key)
{
// Pad for PKCS7
$blockSize = mcrypt_get_block_size(MCRYPT_TWOFISH, MCRYPT_MODE_ECB);
$len = strlen($data);
$pad = $blockSize - ($len % $blockSize);
$data .= str_repeat(chr($pad), $pad);
$encryptedData = mcrypt_encrypt( MCRYPT_TWOFISH, $key, $data, MCRYPT_MODE_ECB);
return $encryptedData;
}
Do you see a problem with this code?