abdelrhmankhodary/cybersec-utils-01

There is no license information available for the latest version (dev-main) of this package.

A PHP library for essential cybersecurity utilities.

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/abdelrhmankhodary/cybersec-utils-01

dev-main 2024-12-27 14:19 UTC

This package is auto-updated.

Last update: 2025-12-27 16:30:01 UTC


README

Overview

CyberSec-Utils is a PHP library providing utilities for cybersecurity-related operations such as encryption, hashing, token generation, and input validation. It is designed to simplify the implementation of secure and reliable functionality in PHP projects.

Features

Encryption

  • Symmetric encryption using AES-256.

Hashing

  • Secure password hashing using password_hash.

Token Generation

  • JSON Web Token (JWT) generation and validation.

Validation

  • Input validation and sanitization for common use cases.

Requirements

  • PHP 8.0 or higher
  • OpenSSL extension (for encryption)

Installation

Using Composer (Recommended)

Add the library to your project:

composer require your-namespace/cybersec-utils

Include the Composer autoload file in your project:

require_once __DIR__ . '/vendor/autoload.php';

Manual Installation

Clone the repository:

git clone https://github.com/your-repo/cybersec-utils.git

Include the library files manually:

require_once __DIR__ . '/src/Encryption/Symmetric.php';
require_once __DIR__ . '/src/Hashing/Password.php';
require_once __DIR__ . '/src/Tokens/JWT.php';
require_once __DIR__ . '/src/Validation/Validation.php';

Usage Examples

Encryption

use CyberSec\Encryption\Symmetric;

$key = 'your-secret-key';
$data = 'Sensitive data';

$encrypted = Symmetric::encrypt($data, $key);
$decrypted = Symmetric::decrypt($encrypted, $key);

echo $decrypted; // Outputs: Sensitive data

Password Hashing

use CyberSec\Hashing\Password;

$password = 'secure-password';
$hashedPassword = Password::hash($password);

if (Password::verify($password, $hashedPassword)) {
    echo 'Password is valid';
}

JSON Web Tokens (JWT)

use CyberSec\Tokens\JWT;

$payload = ['user_id' => 123, 'role' => 'admin'];
$key = 'your-secret-key';

$token = JWT::generate($payload, $key);
$decoded = JWT::validate($token, $key);

print_r($decoded);

Input Validation

use CyberSec\Validation\Validation;

$email = 'test@example.com';
if (Validation::validateEmail($email)) {
    echo 'Valid email';
}

$sanitizedString = Validation::sanitizeString("Hello <script>alert('hi');</script>");
echo $sanitizedString; // Outputs: Hello

Running Tests

To run unit tests:

  1. Ensure PHPUnit is installed via Composer.
  2. Execute the tests:
./vendor/bin/phpunit

Contributing

  1. Fork the repository.
  2. Create a new feature branch:
git checkout -b feature-name
  1. Commit your changes and push to the branch:
git push origin feature-name
  1. Create a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.