Laravel and Lumen Source Code Encrypter

Overview

Laravel Source Encrypter

StyleCI Latest Stable Version License CodeFactor

This package encrypts your php code with phpBolt

For Laravel and Lumen 6, 7, 8

Installation

Step 1

At the first, You have to install phpBolt.

Step 2

Require the package with composer using the following command:

composer require --dev sbamtr/laravel-source-encrypter

Step 3

For Laravel

The service provider will automatically get registered. Or you may manually add the service provider in your config/app.php file:

'providers' => [
    // ...
    \sbamtr\LaravelSourceEncrypter\SourceEncryptServiceProvider::class,
];

For Lumen

Add this line of code under the Register Service Providers section of your bootstrap/app.php:

$app->register(\sbamtr\LaravelSourceEncrypter\SourceEncryptServiceProvider::class);

Step 4 (Optional)

You can publish the config file with this following command:

php artisan vendor:publish --provider="sbamtr\LaravelSourceEncrypter\SourceEncryptServiceProvider" --tag=config

Note: If you are using Lumen, you have to use this package.

Usage

Open terminal in project root and run this command:

php artisan encrypt-source

This command encrypts files and directories in config/source-encrypter.php file. Default values are app, database, routes.

The default destination directory is encrypted. You can change it in config/source-encrypter.php file.

Also the default encryption key length is 6. You can change it in config/source-encrypter.php file. 6 is the recommended key length.

This command has these optional options:

Option Description Example
source Path(s) to encrypt app,routes,public/a.php
destination Destination directory encrypted
keylength Encryption key length 6
force Force the operation to run when destination directory already exists

Usage Examples

Command Description
php artisan encrypt-source Encrypts with default source, destination and keylength. If the destination directory exists, asks for delete it.
php artisan encrypt-source --force Encrypts with default source, destination and keylength. If the destination directory exists, deletes it.
php artisan encrypt-source --source=app Encrypts app directory to the default destination with default keylength.
php artisan encrypt-source --destination=dist Encrypts with default source and key length to dist directory.
php artisan encrypt-source --destination=dist --keylength=8 Encrypts default source to dist directory and the encryption key length is 8.

Written with by Siavash Bamshadnia.

Please support me by staring this repository.

Comments
  • Error While Installing PhpBolt Can You Please Suggest a solution

    Error While Installing PhpBolt Can You Please Suggest a solution

    Problem 1 - Installation request for sbamtr/laravel-source-encrypter ^1.2 -> satisfiable by sbamtr/laravel-source-encrypter[1.2.0]. - sbamtr/laravel-source-encrypter 1.2.0 requires ext-bolt * -> the requested PHP extension bolt is missing from your system.

    To enable extensions, verify that they are enabled in your .ini files: - C:\xampp\php\php.ini You can also run php --ini inside terminal to see which files are used by PHP in CLI mode.

    image

    opened by asqarrsl 5
  • Your requirements could not be resolved to an installable set of packages.

    Your requirements could not be resolved to an installable set of packages.

    Your requirements could not be resolved to an installable set of packages.

    Problem 1 - Root composer.json requires sbamtr/laravel-source-encrypter ^1.4 -> satisfiable by sbamtr/laravel-source-encrypter[1.4.0]. - sbamtr/laravel-source-encrypter 1.4.0 requires illuminate/console ^6|^7|^8|^9 -> found illuminate/console[v6.0.0, ..., 6.x-dev, v7.0.0, ..., 7.x-dev, v8.0. 0, ..., 8.x-dev, v9.0.0-beta.1, ..., 9.x-dev] but these were not loaded, likely because it conflicts with another require.

    You can also try re-running composer require with an explicit version constraint, e.g. "composer require sbamtr/laravel-source-encrypter:*" to figure out if any version is installable, or "composer require sbamtr/laravel-source-encrypter:^2.1" if you know which you need.

    Installation failed, reverting ./composer.json and ./composer.lock to their original content.

    Originally posted by @aashishtimalsina in https://github.com/SiavashBamshadnia/Laravel-Source-Encrypter/issues/7#issuecomment-1237686972

    opened by SiavashBamshadnia 4
  • ERROR  Command

    ERROR Command "encrypt-source" is not defined.

    I have downloaded phpBolt, and placed the required extension in php.ini file, but when I run php artisan encrypt-source, it shows me this error:

    `PHP Warning:  PHP Startup: Unable to load dynamic library '/home/hanif/Downloads/phpBolt-extension-1.0.3/phpBolt-extension-1.0.3/linux 64/linux 64-php8.1' (tried: /home/hanif/Downloads/phpBolt-extension-1.0.3/phpBolt-extension-1.0.3/linux 64/linux 64-php8.1 (/home/hanif/Downloads/phpBolt-extension-1.0.3/phpBolt-extension-1.0.3/linux 64/linux 64-php8.1: cannot read file data: Is a directory), /usr/lib/php/20210902//home/hanif/Downloads/phpBolt-extension-1.0.3/phpBolt-extension-1.0.3/linux 64/linux 64-php8.1.so (/usr/lib/php/20210902//home/hanif/Downloads/phpBolt-extension-1.0.3/phpBolt-extension-1.0.3/linux 64/linux 64-php8.1.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
    
       ERROR  Command "encrypt-source" is not defined.`
    

    I have already restarted my apache2

    I can't see the service provider in my config/app.php. I am using php8.1

    opened by hanifhefaz 2
  • Error after moving project to another PC or uploading to server

    Error after moving project to another PC or uploading to server

    First: thanks for that great tool :+1: Second: I encrypted a laravel project and it was working good in my PC, but after uploading to the server i got the following error

    Fatal error: Uncaught Error: Call to undefined function bolt_decrypt() in xxxxxx/app/Http/Kernel.php:2 Stack trace: #0 xxxxxx/vendor/composer/ClassLoader.php(444): include() #1 xxxxxx/vendor/composer/ClassLoader.php(322): Composer\Autoload\includeFile('/home/stsgulf/p...') #2 [internal function]: Composer\Autoload\ClassLoader->loadClass('App\\Http\\Kernel') #3 [internal function]: spl_autoload_call('App\\Http\\Kernel') #4 xxxxxx/vendor/laravel/framework/src/Illuminate/Container/Container.php(752): ReflectionClass->__construct('App\\Http\\Kernel') #5 xxxxxx/vendor/laravel/framework/src/Illuminate/Container/Container.php(631): Illuminate\Container\Container->build('App\\Http\\Kernel') #6 xxxxxx/vendor/laravel/framework/src/Illuminate/Container/Container.php(586): Illuminate\Container\Container->resolve('App\\Http\\Kernel', in xxxxxx/app/Http/Kernel.php on line 2

    I tried to move it to another PC i got the same error

    Note: I also added the bolt extension to the new PC

    opened by halatef 1
  • File not found exception

    File not found exception

    I got a file not found exception when running the code: ErrorException : file_put_contents(/var/www/......php): failed to open stream: No such file or directory

    The issue can be solved by creating the folders before writing to the files:

    $cipher = bolt_encrypt($fileContents, $key);
    File::isDirectory(dirname("$destination/$filePath")) or File::makeDirectory(dirname("$destination/$filePath"), 0755, true, true);
    File::put(base_path("$destination/$filePath"), $prepend.$cipher);
    

    Keep up the good work!

    opened by hackerkok 0
  • [Feature request] Support encryption of Blade files

    [Feature request] Support encryption of Blade files

    Rather than leaving *.blade.php files unencrypted, please consider adding functionality to encrypt blade files using one of the following methods:

    a. Compile the blade file to raw php and then encrypt it; or

    b. Use a method other than phpBolt to encrypt the blade file, storing the (separate) encryption key for this in a phpBolt encrypted blade file.

    Both of these methods are likely to require some sort of macroed extension to Laravel's blade to handle these without code changes.

    opened by Sophist-UK 2
  • New migration syntax

    New migration syntax

    When, I try to encrypt a migration file

    Old syntax

    class CreateUserTableextends Migration {
    }
    

    Migration works without any issues


    New syntax laravel >=8

    return new class extends Migration {
    };
    

    Migration not working and returning that error Class "CreateUserTable" not found

    opened by Hoopex 9
  • can't install

    can't install

    I get error when install PHP: v7.4.1 Laravel v8.37.0 I installed bolt.so extension and enabled it Screen Shot 2021-06-18 at 21 43 39

    Your requirements could not be resolved to an installable set of packages.
    
      Problem 1
        - Root composer.json requires sbamtr/laravel-source-encrypter 1.3.0 -> satisfiable by sbamtr/laravel-source-encrypter[1.3.0].
        - sbamtr/laravel-source-encrypter 1.3.0 requires ext-bolt * -> it is missing from your system. Install or enable PHP's bolt extension.
    
    opened by ttquoccuong 1
Releases(1.4.0)
Owner
Siavash Bamshadnia
Web and Android developer
Siavash Bamshadnia
CORS Middleware for Lumen micro-framework

Lumen-CORS Cross-origin resource sharing (CORS) Middleware for Lumen micro-framework. Installation After you install lumen as per lumen docs, install

Palani Kumanan 101 Nov 21, 2022
A Simple Cross Origin Resource Sharing for Lumen Framework (5.*).

Lumen Cors Package A Simple Cross Origin Resource Sharing for Lumen Framework. Note: That should works fine on Laravel Framework too, but the tests ar

Vagner Luz do Carmo 46 Jul 27, 2022
JObfuscator — Java Source Code Obfuscation & Protection

JObfuscator is a source code obfuscator for the Java programming language. It can protect your Java source code and algorithms from hacking, cracking, reverse engineering, decompilation, and technology theft.

Bartosz Wójcik 8 Nov 6, 2022
phpcs-security-audit is a set of PHP_CodeSniffer rules that finds vulnerabilities and weaknesses related to security in PHP code

phpcs-security-audit is a set of PHP_CodeSniffer rules that finds vulnerabilities and weaknesses related to security in PHP code.

Floe design + technologies 654 Dec 28, 2022
A minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES.

Current version: 1.3.5 PrivateBin is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted a

null 4.6k Jan 7, 2023
Javascript code scanner to use with gettext/gettext

Javascript code scanner to use with gettext/gettext

Gettext 4 Feb 14, 2022
Laravel Security was created by, and is maintained by Graham Campbell, and is a voku/anti-xss wrapper for Laravel, using graham-campbell/security-core

Laravel Security Laravel Security was created by, and is maintained by Graham Campbell, and is a voku/anti-xss wrapper for Laravel, using graham-campb

Graham Campbell 170 Nov 20, 2022
Automatic Encrypt and Decrypt your database data. Tested and used on Laravel 8

Laravel Encrypt Database Automatic Encrypt and Decrypt your database data. Tested and used on Laravel 8. I'm yet building the tests. Important Note th

Wellington Barbosa 2 Dec 15, 2021
A cryptography API wrapping the Sodium library, providing a simple object interface for symmetrical and asymmetrical encryption, decryption, digital signing and message authentication.

PHP Encryption A cryptography API wrapping the Sodium library, providing a simple object interface for symmetrical and asymmetrical encryption, decryp

null 19 Dec 31, 2022
PHP 5.x support for random_bytes() and random_int()

random_compat PHP 5.x polyfill for random_bytes() and random_int() created and maintained by Paragon Initiative Enterprises. Although this library sho

Paragon Initiative Enterprises 8k Jan 5, 2023
Easy to use cryptographic framework for data protection: secure messaging with forward secrecy and secure data storage. Has unified APIs across 14 platforms.

Themis provides strong, usable cryptography for busy people General purpose cryptographic library for storage and messaging for iOS (Swift, Obj-C), An

Cossack Labs 1.6k Jan 6, 2023
PHPIDS (PHP-Intrusion Detection System) is a simple to use, well structured, fast and state-of-the-art security layer for your PHP based web application

PHPIDS PHPIDS (PHP-Intrusion Detection System) is a simple to use, well structured, fast and state-of-the-art security layer for your PHP based web ap

null 752 Jan 3, 2023
A library for generating random numbers and strings

RandomLib A library for generating random numbers and strings of various strengths. This library is useful in security contexts. Install Via Composer

Anthony Ferrara 832 Nov 24, 2022
Fast, general Elliptic Curve Cryptography library. Supports curves used in Bitcoin, Ethereum and other cryptocurrencies (secp256k1, ed25519, ..)

Fast Elliptic Curve Cryptography in PHP Information This library is a PHP port of elliptic, a great JavaScript ECC library. Supported curve types: Sho

Simplito 178 Dec 28, 2022
A multitool library offering access to recommended security related libraries, standardised implementations of security defences, and secure implementations of commonly performed tasks.

SecurityMultiTool A multitool library offering access to recommended security related libraries, standardised implementations of security defences, an

Pádraic Brady 131 Oct 30, 2022
TCrypto is a simple and flexible PHP 5.3+ in-memory key-value storage library

About TCrypto is a simple and flexible PHP 5.3+ in-memory key-value storage library. By default, a cookie will be used as a storage backend. TCrypto h

timoh 57 Dec 2, 2022
Automatic SQL injection and database takeover tool

sqlmap sqlmap is an open source penetration testing tool that automates the process of detecting and exploiting SQL injection flaws and taking over of

sqlmapproject 25.7k Jan 5, 2023
Ransomware with automatic Coinbase Commerce integration created in C# (Console) and PHP

AWare — C# Ransomware Ransomware with automatic Coinbase Commerce integration created in C# (Console) and PHP PD: AWare is just a proof of concept, wi

in the space 26 Sep 16, 2022