2017 © Pedro Peláez
 

library securehash

Class to encrypt data easily with hash algorithms

image

securehash/securehash

Class to encrypt data easily with hash algorithms

  • Thursday, October 9, 2014
  • by SiroDiaz
  • Repository
  • 1 Watchers
  • 0 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

SecureHash

PHP Class to encrypt data easily with hash algorithms, (*1)

requires PHP 5 >= 5.3.0, (*2)

Composer

$ composer require securehash/securehash:dev-master

Quick Start and Examples

Supported algorithms

md2, md4, md5, sha1, sha224, sha256, sha384, sha512, ripemd128, ripemd160, ripemd256, ripemd320, whirlpool, tiger128,3, tiger160,3, tiger192,3, tiger128,4, tiger160,4, tiger192,4, snefru, snefru256, gost, adler32, crc32, crc32b, salsa10(non supported in PHP 5.4.0 and later), salsa20(non supported in PHP 5.4.0 and later), 'haval128,3', 'haval160,3', 'haval192,3', 'haval224,3', 'haval256,3', 'haval128,4', 'haval160,4', 'haval192,4', 'haval224,4', 'haval256,4', 'haval128,5', 'haval160,5', 'haval192,5', 'haval224,5' and 'haval256,5'., (*3)

SecureHash class

Methods

getValue, getAlgo, getAlgorithms, setValue, setAlgo, cifrate, cifrateFile, cifrateUrl, cifrateMultiple, cifrateMultipleFiles, cifrateMultipleUrls, compare, compareFiles, compareUrls, (*4)

Examples

Simple string hashing., (*5)

require 'Secure.php';
// 'as SH' is to set an alias of SecureHash class name
// and it is optional
use Secure\SecureHash as SH;

$a = new SH('sha512', 'Hello World!');
echo $a->cifrate();

Hashing a file., (*6)

require 'Secure.php';
use Secure\SecureHash as SH;

$a = new SH();  // defaults algorithm md5 and default value ''
$a->setAlgo('crc32');
$a->setValue('css/normalize.css');  // change the value to be encrypted
echo $a->cifrateFile();

Print all algorithms implemented by PHP in your current version, (*7)

require 'Secure.php';
use Secure\SecureHash as SH;

$a = new SH();
var_dump($a->getAlgorithms());

Check if two urls contains the same data, (*8)

require 'Secure.php';
use Secure\SecureHash as SH;

$jqueryGoogle = 'http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js';
$jqueryjQuery = 'http://code.jquery.com/jquery-2.1.1.min.js';

$a = new SH('ripped160');
var_dump($a->compareUrls($jqueryGoogle, $jqueryjQuery));    // true if are equals, false if not

Encrypt the content of multiple urls, (*9)

require 'Secure.php';
use Secure\SecureHash as SH;

$urls = array(
    'http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js',
    'http://code.jquery.com/jquery-2.1.1.min.js'
);

$a = new SH('sha512')
$cifratedUrls = $a->cifrateMultipleUrls($urls); // returns an array with the data encripted
var_dump($cifratedUrls);

Static class version: methods and examples

Methods

getAlgorithms, cifrate, cifrateFile, cifrateUrl, cifrateMultiple, cifrateMultipleFiles, cifrateMultipleUrls, compare, compareFiles, compareUrls, (*10)

Examples

Simple string hashing., (*11)

require 'SecureStatic.php';
// 'as SH' is to set an alias of SecureHash class name
// and it is optional
use Secure\SecureStatic\SecureHash as SH;

echo SH::cifrate('sha512', 'Hello World!');

Hashing a file., (*12)

require 'SecureStatic.php';
use Secure\SecureStatic\SecureHash as SH;

echo SH::cifrateFile('md4', 'route/to/file.extension');

Print all algorithms implemented by PHP in your current version, (*13)

require 'SecureStatic.php';
use Secure\SecureStatic\SecureHash as SH;

var_dump(SH::getAlgorithms());

Check if two urls contains the same data, (*14)

require 'SecureStatic.php';
use Secure\SecureStatic\SecureHash as SH;

$jqueryGoogle = 'http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js';
$jqueryjQuery = 'http://code.jquery.com/jquery-2.1.1.min.js';

// true if are equals, false if not
var_dump(SH::compareUrls('ripped160', $jqueryGoogle, $jqueryjQuery));

Encrypt the content of multiple urls, (*15)

require 'SecureStatic.php';
use Secure\SecureStatic\SecureHash as SH;

$urls = array('http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js', 'http://code.jquery.com/jquery-2.1.1.min.js');

$cifratedUrls = SH::cifrateMultipleUrls('sha512', $urls);   // returns an array with the data encripted
var_dump($cifratedUrls);

The Versions

09/10 2014

dev-master

9999999-dev

Class to encrypt data easily with hash algorithms

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

helpers url files utility data string secure hash methods algorithms