Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include('phpseclib1.0.16/Crypt/RSA.php');
- include('/phpseclib1.0.16/Math/BigInteger.php');
- $client = Yii::$app->soapApi;
- $sha256Pass = hash("sha256", Yii::$app->params['passCode']); //perform SHA-256 of the password
- $result = new \Math_BigInteger($sha256Pass, 16); //in base-16
- $exponent= Yii::$app->params['exponent']; //this value will be replaced with what was documented
- $modulus= Yii::$app->params['modulus']; //this value will be replaced with what was documented
- $crypt_rsa = new \Crypt_RSA();
- $crypt_rsa->loadKey(
- array(
- 'e' => new \Math_BigInteger($exponent),
- 'n' => new \Math_BigInteger($modulus)
- )
- );
- $encryptedPassword = base64_encode($crypt_rsa->encrypt($result));
- $parameters = [
- 'username' =>'usertest1a',
- 'password' => $encryptedPassword,
- 'orgid' => '1184'
- ];
- var_dump($client->createTokenString($parameters));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement