PHP Classes

Encryption Helper: Encrypt and decrypt of GET query lists

Recommend this page to a friend!
  Info   View files Example   View files View files (9)   DownloadInstall with Composer Download .zip   Reputation   Support forum (3)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 55%Total: 317 This week: 1All time: 7,248 This week: 571Up
Version License PHP version Categories
encryption-helper 1.0.1GNU General Publi...7.0Cryptography, PHP 7
Description 

Author

This class can encrypt and decrypt of GET query lists.

It can take a list of parameters and builds a query parameter list like those used to passed to GET parameters.

The class adds a special parameter value with the checksum of all parameter values. The result query string can be encrypted with a given key.

It can also decrypt a previously encrypted data value that contains the query string.

The class can extract the parameter values and check if the checksum parameter is correct.

Innovation Award
PHP Programming Innovation award winner
October 2016
Winner


Prize: One downloadable e-book of choice by O'Reilly
One way to serialize a list of key-value pairs is to use the URL encoding that is use to form query parameters of a GET request by using = to separate the key from the value and & to separate each key-value pair.

If you want to transmit lists of values serialized this way and avoid the values can be seen by unauthorized people, you can use encryption.

However, if somebody can break the encryption and alter the values in transit you may not be able to detect if the values were altered.

This class implements a solution that uses encryption but also adds a checksum value, so in the receiving end it can be verified any changes in the transmited values.

Manuel Lemos
Picture of Michael Cummings
  Performance   Level  
Name: Michael Cummings <contact>
Classes: 9 packages by
Country: United States United States
Age: ???
All time rank: 1897263 in United States United States
Week rank: 420 Up49 in United States United States Up
Innovation award
Innovation award
Nominee: 7x

Winner: 1x

Recommendations

Decrypt C# Encryption String with PHP is this possible?
I want to Decrypt the C# Encryption string in php

Example

<?php
declare(strict_types = 1);
/**
 * Created by PhpStorm.
 * User: Dragonaire
 * Date: 10/24/2016
 * Time: 3:47 PM
 */
require_once __DIR__ . '/src/EncryptionHelper.php';
print
'For more complete testing examples see the PHPSpec in specs/Spec/' . PHP_EOL;
$encryptedData = 'F7EBC908B106D4282FA705D0EED915DBE002774B1A152DCC';
print
'$encryptedData = ' . $encryptedData . PHP_EOL;
$eh = new \EncryptionHelper\EncryptionHelper($encryptedData);
$toString = $eh . '';
print
'$toString = ' . $toString . PHP_EOL;
$encrypted = $eh->encrypt($toString);
print
'$encrypted = ' . $encrypted . PHP_EOL;
if (
$encrypted === $encryptedData) {
    print
'Good, the encryption worked right.' . PHP_EOL;
} else {
    print
'Sad, the encryption did not work right.' . PHP_EOL;
}
$decrypted = $eh->decrypt($encrypted);
print
'$decrypted = ' . $decrypted . PHP_EOL;
if (
$decrypted === $toString) {
    print
'Great! Got back what we started with.';
} else {
    print
'Oops! Did not get back what we started with.';
}


Details

Encryption Helper

Class is made to help with the encryption and decryption of GET queries. It was create to replace a c# class of the same name that was posted in a request on PHPClasses.


  Files folder image Files  
File Role Description
Files folder imagecSharp (1 file)
Files folder imagespecs (1 directory)
Files folder imagesrc (1 file)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file example.php Example Example script
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file phpspec.yml.dist Data Auxiliary data
Accessible without login Plain text file phpspec_coverage.yml Data Auxiliary data
Accessible without login Plain text file README.md Data Description

  Files folder image Files  /  cSharp  
File Role Description
  Accessible without login Plain text file EncryptionHelper.cs Data Auxiliary data

  Files folder image Files  /  specs  
File Role Description
Files folder imageSpec (1 file)

  Files folder image Files  /  specs  /  Spec  
File Role Description
  Accessible without login Plain text file EncryptionHelperSpec.php Test Behavior test class

  Files folder image Files  /  src  
File Role Description
  Plain text file EncryptionHelper.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:317
This week:1
All time:7,248
This week:571Up
User Ratings User Comments (2)
 All time
Utility:68%StarStarStarStar
Consistency:62%StarStarStarStar
Documentation:-
Examples:68%StarStarStarStar
Tests:81%StarStarStarStarStar
Videos:-
Overall:55%StarStarStar
Rank:1917