Example #1
0
 /**
  * Login with post'ed username and encrypted password.
  *
  * @return \Zend\Http\Response
  */
 protected function login()
 {
     // Fetch Salt
     $salt = $this->generateSalt();
     // HexDecode Password
     $password = pack('H*', $this->params()->fromPost('password'));
     // Decrypt Password
     $password = \VuFind\Crypt\RC4::encrypt($salt, $password);
     // Update the request with the decrypted password:
     $this->getRequest()->getPost()->set('password', $password);
     // Authenticate the user:
     try {
         $this->getAuthManager()->login($this->getRequest());
     } catch (AuthException $e) {
         return $this->output($this->translate($e->getMessage()), self::STATUS_ERROR);
     }
     return $this->output(true, self::STATUS_OK);
 }
Example #2
0
 /**
  * Test encryption/decryption.
  *
  * @return void
  */
 public function testEncryptionAndDecryption()
 {
     $key = 'secret';
     $text = 'test';
     $this->assertEquals($text, RC4::decrypt($key, RC4::encrypt($key, $text)));
 }