MightyPHP comes equipped with a secure encryption and decryption helper functions: encrypt(), decrypt().

Prior to using these, it is required that APP_KEY is present within your .env file. In order to generate one, you may run php mighty key:generate.

The helper functions are also accessible through your HTML or Twig files via the Twig function with the similar method syntax:

<div>{{ encrypt('test') }}</div>
<div>{{ decrypt('897352ovnsdknf9183iahusd372') }}</div>

To use it anywhere within your codebase, just call upon the helper functions as such:

namespace Application\Controllers;
use Application\Controllers\Controller;
use MightyCore\Http\Request;
class FooController extends Controller
public function encrypt(Request $request){
return encrypt('Hello World');
public function decrypt(Request $request){
return decrypt($request->query('id'));