What's wrong with zakodirovana in RSA password?

public function postCheckValidAuth() {
 $username = $this->request->getContent['login'];
 $password = $this->request->getContent['password'];


 $url = 'https://store.steampowered.com/login/getrsakey/';
 $data = ['username' => $username, 'password' => $password];

 $result = $this->post($url, $data);
 $result = json_decode($result);

 $rsa = new RSA();
 $key = [
 'modulus' => new BigInteger($result->publickey_mod, 16),
 'publicExponent' => new BigInteger($result->publickey_exp, 16)
];

 $rsa->loadKey($key, RSA::PUBLIC_FORMAT_RAW);
 $password = base64_encode($rsa->encrypt($password, false));
 $captchaGid = -1;
 $captchaText = ";
 $emailAuth = ";
 $emailSteamId = ";

 $data = [
 'username' => $username,
 'password' => $password,
 'rsatimestamp' => $result->timestamp,
 'captcha_gid' => $captchaGid,
 'captcha_text' => $captchaText,
 'emailauth' => $emailAuth,
 'emailsteamid' => $emailSteamId
];

 $url = 'https://store.steampowered.com/login/dologin/';

 $result = $this->post($url, $data);
 $result= json_decode($result);

$this->response->setJsonContent($result)->send();
}

 private function post($url, $data) {
$curl_handle=curl_init();
 curl_setopt($curl_handle, CURLOPT_URL, $url);
 curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 3);
 curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
 curl_setopt($curl_handle, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36');
 curl_setopt($curl_handle, CURLOPT_POST, 1);
 curl_setopt($curl_handle, CURLOPT_POSTFIELDS, http_build_query($data));
 $query = curl_exec($curl_handle);
curl_close($curl_handle);

 return $query;
 }


Something wrong with zakodirovana password?
Keeps displaying that the password is not correct, although he is 100% correct.
June 5th 19 at 21:01
2 answers
June 5th 19 at 21:03
Solution
$rsa = new RSA();
$key = [
 'modulus' => new BigInteger($result->publickey_mod, 16),
 'publicExponent' => new BigInteger($result->publickey_exp, 16)
];
$rsa->loadKey($key, RSA::PUBLIC_FORMAT_RAW);
$rsa->setPublicKey($key);
$rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1);
$password = base64_encode($rsa->encrypt($password));
June 5th 19 at 21:05
$password = base64_encode($rsa->encrypt($password, false));

Your main mistake, there is an automatic method RSA encryption in Base64, and then as you generate bays, and decode
And what kind of automatic method of encryption in Base64? - annabelle17 commented on June 5th 19 at 21:08

Find more questions by tags APIPHPRSASteam