I have found the following decrypt function online. Other decrypt functions that I have found are a varation of this function:
public function Decrypt($data) {
$crypt = base64_decode($data);
$iv_size = mcrypt_get_iv_size($this->Algo, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
$decrypt = mcrypt_decrypt($this->Algo, $this->Key, $crypt, MCRYPT_MODE_ECB, $iv);
$block = mcrypt_get_block_size('blowfish', 'ecb');
$pad = ord($decrypt[($len = strlen($decrypt)) - 1]);
return substr($decrypt, 0, strlen($decrypt) - $pad);
}
My question is the following: The ord() function gives the ASCII value of a character. Then this ASCII value is used in a calculation which involves the string length. Why is that the case? (It seems to me that whichever ASCII value a padding is made of should not be used together with string length.)