Exemplo n.º 1
0
 protected function encryptSsoData($ssoData)
 {
     $site = $ssoData['site'];
     unset($ssoData['user'], $ssoData['site']);
     $userData = $ssoData['user_data'];
     $key = fnGet($site, 'site_secret');
     $userData['sign'] = Security::signArrayHmacSha256($userData, $key);
     $ssoData['user_data'] = Crypt::opensslEncrypt(json_encode($userData), $key);
     return $ssoData;
 }
Exemplo n.º 2
0
 public function testOpensslEncryptDecrypt()
 {
     $key = 'BnIv15w06qnvibLuuRfVSP9qb9MLPKFg';
     $text = json_encode(['abc' => 'def', 'xxx1' => 'ooo', 'xxx2' => 'ooo', 'xxx3' => 'ooo', 'xxx4' => 'ooo']);
     $encrypted = Crypt::opensslEncrypt($text, $key);
     $this->assertNotEmpty($encrypted, 'Unable to encrypt');
     $decrypted = Crypt::opensslDecrypt($encrypted, $key);
     $this->assertNotEmpty($decrypted, 'Unable to decrypt');
     $this->assertEquals($text, $decrypted, 'Bad decrypted text');
 }