2017 © Pedro Peláez
 

library simple-php-encryptor

Simple PHP Encryption

image

ricbarbo/simple-php-encryptor

Simple PHP Encryption

  • Thursday, August 10, 2017
  • by snake03
  • Repository
  • 1 Watchers
  • 1 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Simple PHP Encryption Static Class.

Encrypt and decrypt any message using two secret phrases., (*1)

The main advantage over the built-in encryption methods is that the encrypted message has the same length of the original message, so it's often very short and it's ideal for creating authentication keys or access tokens and passing them with GET or POST requests., (*2)

This algorithm is very basic stuff, use it at your own risk., (*3)

Examples

Encrypt any message. It will return a string of the same length of the sentence encrypted, (*4)

Encryption::encrypt("My Secret Sentence"), (*5)

Decrypt a message previously encrypted, (*6)

Encryption::decrypt("EaNQhIuWVH6enZ+dh6ipl6GliFfSp4GknpqFhc6lsbbLyYN+"), (*7)

Sign a message. It will ouput a 20 characters long string., (*8)

Encryption::sign("Andrew"), (*9)

Detect if the signature of the message is valid. It return a boolean, true if it's valid, false otherwise., (*10)

Encryption::hasValidSignature("Andrew", "aoi28CA91ncuaF910s1E"), (*11)

Example: Token generation

In the examples folder you will find a simple Token generation case. If you want to create a simple access token for a user, you may want to grab the user's id and the current timestamp, sign them together, encrypt them and pass this generated token to the user., (*12)

When the user append this token to a request, you can decrypt it, verify the signature, check if it's still valid (in the example the token has a 1 week validity) and use user's id., (*13)

The Versions

10/08 2017

dev-master

9999999-dev

Simple PHP Encryption

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

by Riccardo Barbotti