Skip to content

Simple, easy-to-use and effective PHP Encryption class. It's a standalone single file PHP class to use on your projects.

License

Notifications You must be signed in to change notification settings

devwithkunal/php-encrypt-decrypt-class

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

PHP Encrypt/Decrypt Class

Simple, easy-to-use and effective PHP Encryption class. It's a standalone single file PHP class to use on your projects. It requires no dependencies or no framework.

How To Use

You only need only one file:

  • Encryption.php

You can run everything from the index.php file, see the file for usage.

Step 1 - Initialize

// Include the class file
require 'Encryption.php';

// Set a secret key
const KEY = 'secretkey';

// Message string to encode
$message = 'Hello world';

Step 2 - Encrypt

$encoded_text = Encryption::Encode($message, KEY);
//@return d1pXc2dsYVBqQ0NrSkJ1Zy85RWprUT09

Step 3 - Decrypt

$decoded_text = Encryption::Decode($encoded_text, KEY);
//@return Hello world

More

  • This code uses openssl for encrypt & decrypt data. See PHP Manual for more information.
  • Default encryption method is AES-256-CBC. You can change it on Encryption.php file at line 14 & 29. Or you can enter it as thrid parameter on both static mathods.

LICENSE

MIT License

About

Simple, easy-to-use and effective PHP Encryption class. It's a standalone single file PHP class to use on your projects.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages