nael_d/encrypia

Encrypia: Securely encrypt and decrypt text data with our custom PHP-based encryption class.

v2.0.0 2024-09-11 00:00 UTC

This package is auto-updated.

Last update: 2025-03-11 17:19:55 UTC


README

Securely encrypt and decrypt text data with our custom PHP-based encryption class.

Key Features

  • Blind & Unblind: Encrypt and decrypt text using a unique key you provide.
  • PHP Compatibility: Works with PHP versions 7.0.0 and above.

Installation

Installing Encrypia is available through Composer:

composer install nael_d/encrypia

Alternatively, you can download latest Encrypia version manually from GitLab.

Getting started

Encrypia requires you to set a custom key using setKey():

Encrypia::setKey(1234567890);

💡 For enhanced security, we recommend using a key with at least 8 characters.

Encrypia employs the blind() method for encryption and the unblind() method for decryption. A unique encryption key is required for secure data handling.

// Encrypt a message
Encrypia::setKey(6537791);
$encryptedText = Encrypia::blind('Hello world!');
echo $encryptedText;
// output: Y8b6H3D6KPKw0yjH37Gk6276TIYPEpIktNrIKkKw5Sk=

// Decrypt the message
$decryptedText = Encrypia::unblind($encryptedText);
echo $decryptedText;
// Output: Hello world!

Encrypia offers flexibility by allowing you to specify a custom encryption key for individual operations, while maintaining the global key for consistent encryption and decryption.

Encrypia::setKey(6537791); // global key
echo Encrypia::blind('Hello world!', 991340785); // passing custom key
// output: 1vumtX0sQsauiWV3pUfdt3ChbbRG6UzLIhw+bhU9KTY=

echo Encrypia::unblind('1vumtX0sQsauiWV3pUfdt3ChbbRG6UzLIhw+bhU9KTY=', 991340785);
// output: Hello world!

Advanced Settings

Encrypia comes up with adnvaned settings using settings() with this options:

  • ENC_COMPRESS: compresses texts to reduce size for efficient storing.

    Encrypia::settings(Encrypia::ENC_COMPRESS);
    
  • ENC_SECURE_KEY: encrypts the secret key for more encryption level.

    Encrypia::settings(Encrypia::ENC_SECURE_KEY);
    

You may combine multiple settings using pipepline |:

Encrypia::settings(
  Encrypia::ENC_COMPRESS | Encrypia::ENC_SECURE_KEY
);

Conditions of usage

Encrypia is free to use in all your projects, Commercial and Personal.