我有一个客户端使用oracle传递身份验证,我无法正确加密。
这是我从客户那里获得的所有信息:
到目前为止,我有以下代码,但我不是100%我正在进行加密,并且还不知道如何实现RSSL_PAD_ISO10126填充,或者如何处理PKCS5-V20 keygen。我在这里发现另一篇文章解释说aes256加密是MCRYPT_RIJNDAEL_128。任何有关如何进行的信息将不胜感激。
public static function ptaLink($pid, $params = [])
{
$url = \Config::get('chat.ptaBaseUrl');
$params['p_userid'] = $pid;
$params['p_ccf_1'] = $pid;
$ptaDataString = self::buildParams($params);
return $url.$ptaDataString;
}
public static function buildParams($params) {
$defaultParams = [
'p_userid' => '', // PID
'p_passwd' => '',
'p_ccf_1' => '', // PID
'p_li_expiry' => time(),
];
$params = array_merge($defaultParams, $params);
//Convert PTA data array to string
$ptaDataString = "";
foreach($params as $key=>$value)
{
$ptaDataString .= ($ptaDataString === "") ? '' : '&';
$ptaDataString .= "$key=$value";
}
$ptaDataString = self::encryptData($ptaDataString);
return $ptaDataString;
}
public static function encryptData($text) {
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
$iv = mcrypt_create_iv($iv_size, MCRYPT_DEV_URANDOM);
$key = \Config::get('chat.secretKey');
$crypttext = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $text, MCRYPT_MODE_CBC, $iv);
//Base64 encode the data
$ptaDataString = base64_encode($crypttext);
//Make sure the data is URL safe
$ptaDataString = strtr($ptaDataString, array('+' => '_', '/' => '~', '=' => '*'));
return $ptaDataString;
}