PayPal\Auth\OAuthTokenCredential::encrypt PHP Method

encrypt() public method

Helper method to encrypt data using clientSecret as key
public encrypt ( $data ) : string
$data
return string
    public function encrypt($data)
    {
        return $this->cipher->encrypt($data);
    }

Usage Example

 public function testGetAccessTokenUnit()
 {
     $config = array('mode' => 'sandbox', 'cache.enabled' => true, 'cache.FileName' => AuthorizationCacheTest::CACHE_FILE);
     $cred = new OAuthTokenCredential('clientId', 'clientSecret');
     //{"clientId":{"clientId":"clientId","accessToken":"accessToken","tokenCreateTime":1421204091,"tokenExpiresIn":288000000}}
     AuthorizationCache::push($config, 'clientId', $cred->encrypt('accessToken'), 1421204091, 288000000);
     $apiContext = new ApiContext($cred);
     $apiContext->setConfig($config);
     $this->assertEquals('clientId', $cred->getClientId());
     $this->assertEquals('clientSecret', $cred->getClientSecret());
     $result = $cred->getAccessToken($config);
     $this->assertNotNull($result);
 }