GithubHelp home page GithubHelp logo

oceanjack / gibberish-aes-php Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ivantcholakov/gibberish-aes-php

0.0 1.0 0.0 51 KB

A PHP port of Gibberish AES javascript encryption library, https://github.com/mdp/gibberish-aes

License: MIT License

PHP 100.00%

gibberish-aes-php's Introduction

Gibberish AES, a PHP Implementation

See Gibberish AES javascript encryption library, https://github.com/mdp/gibberish-aes

An important note: The complementary JavaScript project Gibberish AES has been deprecated, see mdp/gibberish-aes#25
Consider finding alternative PHP and JavaScript solutions.

This class is based on initial code proposed by nbari at dalmp dot com http://www.php.net/manual/en/function.openssl-decrypt.php#107210

Live Demo

http://iridadesign.com/starter-public-edition-4/www/playground/gibberish-aes

Requirements:

  • OpenSSL functions installed and PHP version >= 5.3.3

or

  • Mcrypt functions installed and PHP version < 7.1.0-alpha

For PHP under version 7 it is recommendable you to install within your project "PHP 5.x support for random_bytes() and random_int()", https://github.com/paragonie/random_compat

Usage Example:

echo '<br />';

// This is a secret pass-phrase, keep it in a safe place and don't loose it.
$pass = 'my secret pass-phrase, it should be long';
echo '$pass = '.$pass;
echo '<br />';
// The string to be encrypted.
$string = 'my secret message';
echo '$string = '.$string;
echo '<br />';
echo '<br />';

// The default key size is 256 bits.
$old_key_size = GibberishAES::size();

echo 'Encryption and decryption using a 256-bit key:';
echo '<br />';
GibberishAES::size(256);
// This is the result after encryption of the given string.
$encrypted_string = GibberishAES::enc($string, $pass);
// This is the result after decryption of the previously encrypted string.
// $decrypted_string == $string (should be).
$decrypted_string = GibberishAES::dec($encrypted_string, $pass);
echo '$encrypted_string = '.$encrypted_string;
echo '<br />';
echo '$decrypted_string = '.$decrypted_string;
echo '<br />';
echo '<br />';

echo 'Encryption and decryption using a 192-bit key:';
echo '<br />';
GibberishAES::size(192);
$encrypted_string = GibberishAES::enc($string, $pass);
$decrypted_string = GibberishAES::dec($encrypted_string, $pass);
echo '$encrypted_string = '.$encrypted_string;
echo '<br />';
echo '$decrypted_string = '.$decrypted_string;
echo '<br />';
echo '<br />';

echo 'Encryption and decryption using a 128-bit key:';
echo '<br />';
GibberishAES::size(128);
$encrypted_string = GibberishAES::enc($string, $pass);
$decrypted_string = GibberishAES::dec($encrypted_string, $pass);
echo '$encrypted_string = '.$encrypted_string;
echo '<br />';
echo '$decrypted_string = '.$decrypted_string;
echo '<br />';
echo '<br />';

// Restore the old key size.
GibberishAES::size($old_key_size);

Author: Ivan Tcholakov, 2012-2016.
License: The MIT License (MIT), http://opensource.org/licenses/MIT

A fragment of code is under the New BSD License, George Argyros, 2012.

gibberish-aes-php's People

Contributors

ivantcholakov avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.