PHPackages                             effectra/security - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. effectra/security

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

effectra/security
=================

The Effectra Security package.

v1.0.0(3y ago)0221MITPHP

Since Jun 19Pushed 3y agoCompare

[ Source](https://github.com/effectra/security)[ Packagist](https://packagist.org/packages/effectra/security)[ RSS](/packages/effectra-security/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (1)

Effectra Security
=================

[](#effectra-security)

Effectra\\Security is a PHP library that provides security-related functionalities such as hashing, password management, CSRF token handling, and token generation.

Features
--------

[](#features)

- Hashing: Securely hash data using various algorithms.
- Password Management: Generate and verify hashed passwords.
- CSRF Protection: Generate and validate CSRF tokens for web applications.
- Token Generation: Create and decode JSON Web Tokens (JWT).

Requirements
------------

[](#requirements)

- PHP 7.0 or higher

Installation
------------

[](#installation)

You can install the Effectra\\Security library via Composer. Run the following command in your project directory:

```
composer require effectra/security
```

Usage
-----

[](#usage)

### Hashing

[](#hashing)

The `Effectra\Security\Hash` class provides methods for hashing data using HMAC algorithms.

Example usage:

```
use Effectra\Security\Hash;

$data = 'Hello, World!';
$key = 'secret-key';

$hash = Hash::set($data, $key);
echo "Hashed value: " . $hash;
```

### Password Management

[](#password-management)

The `Effectra\Security\Hash` class also includes methods for securely managing passwords.

Example usage:

```
use Effectra\Security\Hash;

$password = 'password123';

$hashedPassword = Hash::setPassword($password);
echo "Hashed password: " . $hashedPassword;

$isPasswordValid = Hash::verifyPassword($password, $hashedPassword);
if ($isPasswordValid) {
    echo "Password is valid.";
} else {
    echo "Password is invalid.";
}
```

### CSRF Protection

[](#csrf-protection)

The `Effectra\Security\Csrf` class provides functionality for generating and validating CSRF tokens.

Example usage:

```
use Effectra\Security\Csrf;
use Effectra\Session\Session; // Replace with your own session implementation

// Initialize the CSRF class with a session instance
$session = new Session();
$csrf = new Csrf($session);

// Generate and insert a CSRF token in your HTML form
$html = '';
$html .= $csrf->insertHiddenToken();
$html .= '';
$html .= '';

echo $html;

// Validate the CSRF token on form submission
if ($csrf->validate()) {
    echo "CSRF token is valid.";
} else {
    echo "CSRF token is invalid.";
}
```

### Token Generation

[](#token-generation)

The `Effectra\Security\Token` class allows you to generate and decode JSON Web Tokens (JWT).

Example usage:

```
use Effectra\Security\Token;

$data = ['user_id' => 123];

$config = (object) [
    'issued_at' => time(),
    'expirationTime' => time() + 3600, // Expiration time 1 hour from now
    'issuer' => 'example.com',
    'key' => 'your-secret-key'
];

$token = new Token();
$encodedToken = $token->set($data, $config);
echo "Encoded token: " . $encodedToken;

$decodedToken = $token->get($encodedToken, $config);
echo "Decoded token: ";
print_r($decodedToken);
```

Contributing
------------

[](#contributing)

Contributions are welcome! Feel free to submit bug reports, feature requests, or pull requests on the [GitHub repository](https://github.com/effectra/security).

License
-------

[](#license)

Effectra\\Security is licensed under the [MIT License](https://opensource.org/licenses/MIT).

Credits
-------

[](#credits)

Effectra\\Security is developed and maintained by [Effectra](https://www.effectra.com).

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1111d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7e6219ae87e98df8783b2f595b013035dd183c0712afd24045a8acf0a40c3bdf?d=identicon)[effectra](/maintainers/effectra)

---

Top Contributors

[![BMTmohammedtaha](https://avatars.githubusercontent.com/u/95439605?v=4)](https://github.com/BMTmohammedtaha "BMTmohammedtaha (15 commits)")

---

Tags

csrf-protectionhashhash-passwordjwtphpsecuritytokenxss

### Embed Badge

![Health badge](/badges/effectra-security/health.svg)

```
[![Health](https://phpackages.com/badges/effectra-security/health.svg)](https://phpackages.com/packages/effectra-security)
```

###  Alternatives

[google/auth

Google Auth Library for PHP

1.4k294.2M219](/packages/google-auth)[thenetworg/oauth2-azure

Azure Active Directory OAuth 2.0 Client Provider for The PHP League OAuth2-Client

25310.7M83](/packages/thenetworg-oauth2-azure)[stevenmaguire/oauth2-keycloak

Keycloak OAuth 2.0 Client Provider for The PHP League OAuth2-Client

2306.4M45](/packages/stevenmaguire-oauth2-keycloak)[robsontenorio/laravel-keycloak-guard

🔑 Simple Keycloak Guard for Laravel

5181.2M3](/packages/robsontenorio-laravel-keycloak-guard)[ellaisys/aws-cognito

Laravel Authentication using AWS Cognito (Web and API)

123256.9k1](/packages/ellaisys-aws-cognito)[rainlab/user-plugin

User plugin for October CMS

11955.0k15](/packages/rainlab-user-plugin)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
