mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-01 12:19:28 +00:00
Added new CryptLib as a collection of different encryption/hashing algorithms based on phpseclib
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
use phpseclib\Crypt\Rijndael;
|
||||
|
||||
/**
|
||||
* Collection of different encryption/hashing algorithms
|
||||
*/
|
||||
class CryptLib
|
||||
{
|
||||
/**
|
||||
* Encrypt using the Rijndael algorithm with a key length of 256 bits and the ECB mode
|
||||
* It is possible to disable the padding, enabled by default
|
||||
*/
|
||||
public static function RIJNDAEL_256_ECB($value, $key, $paddingDisabled = false)
|
||||
{
|
||||
if (isEmptyString($key) || strlen($value) % 32 != 0) return null;
|
||||
|
||||
$cipher = new Rijndael(Rijndael::MODE_ECB);
|
||||
$cipher->setBlockLength(256);
|
||||
$cipher->setKey($key);
|
||||
|
||||
if ($paddingDisabled === true) $cipher->disablePadding();
|
||||
|
||||
return $cipher->encrypt($value);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user