Advertisement
Guest User

Untitled

a guest
Sep 28th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1.  
  2. //Generate API User Password
  3. $length2 = 16;
  4. $randomKey = substr(str_shuffle(str_repeat($x='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^*()/\[]', ceil($length/strlen($x)) )),1,$length2);
  5. // $password = $client->oneWayEncrypt(['plainText'=>$randomKey, 'crytoKey'=>'tranglo123']);
  6. // $password = json_decode(json_encode($password), true);
  7. // $password = $password['oneWayEncryptResult'];
  8. // correct method to call (2017-02-02)
  9. $password = $client->sEncryptData(['plainText'=>$randomKey, 'crytoKey'=> Yii::$app->params['soapclient.crytokey']] );
  10. $password = $password->sEncryptDataResult;
  11.  
  12. //END: Generate API User Password
  13.  
  14. //Generate API Security Key
  15. $length3 = 16;
  16. $randomKey2 = substr(str_shuffle(str_repeat($x='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^*()/\[]', ceil($length/strlen($x)) )),1,$length3);
  17. // $secure_ans = $client->oneWayEncrypt(['plainText'=>$randomKey2, 'crytoKey'=>'tranglo123']);
  18. // $secure_ans = json_decode(json_encode($secure_ans), true);
  19. // $secure_ans = $secure_ans['oneWayEncryptResult'];
  20. $secure_ans = $client->sEncryptData(['plainText'=>$randomKey2, 'crytoKey'=> Yii::$app->params['soapclient.crytokey']] );
  21. $secure_ans = $secure_ans->sEncryptDataResult;
  22. //END: Generate API Security Key
  23.  
  24. $password2 = $client->sEncryptData(['plainText'=>$randomKey, 'crytoKey'=>Yii::$app->params['soapclient.crytokey2']]);
  25. $password2 = json_decode(json_encode($password2), true);
  26. $password2 = $password2['sEncryptDataResult'];
  27.  
  28. $systemuser = Yii::$app->db2->createCommand()->update(
  29. 'systemusers',
  30. [
  31. 'Username' => $apiUserId,
  32. 'Password' => $password2
  33. ],
  34. [
  35. 'rspid' => $partner_staging->RspId,
  36. 'category' => 1
  37. ]
  38. );
  39.  
  40. $systemuser->execute();
  41.  
  42. $SecurityKey = Yii::$app->db2->createCommand()->update(
  43. 'SecurityKey',
  44. [
  45. 'HashKey' => $randomKey
  46. ],
  47. [
  48. 'RSPID' => $partner_staging->RspId
  49. ]
  50. );
  51.  
  52. $SecurityKey->execute();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement