예제 #1
0
 public function testSignArrayHmacSha256()
 {
     $data = ['foo' => 'bar'];
     $secret = 'some-stuff';
     $sign = Security::signArrayHmacSha256($data, $secret);
     $this->assertEquals($sign, Security::signArrayHmacSha256($data, $secret));
 }
예제 #2
0
파일: SsoTrait.php 프로젝트: phwoolcon/auth
 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;
 }
예제 #3
0
 public function verifyRsaSign(array $data, $sign)
 {
     unset($data['sign'], $data['sign_type']);
     $string = Security::prepareSignatureData($data);
     $publicKey = openssl_pkey_get_public($this->config['ali_public_key']);
     $result = openssl_verify($string, base64_decode($sign), $publicKey);
     openssl_free_key($publicKey);
     return $result == 1;
 }