bludit/bl-kernel/helpers/crypt.class.php

42 lines
881 B
PHP
Raw Normal View History

2015-08-03 02:49:12 +02:00
<?php defined('BLUDIT') or die('Bludit CMS.');
2015-03-08 18:02:59 +01:00
class Crypt {
// return string
public static function encrypt($string, $key)
{
if(function_exists('get_loaded_extensions'))
{
if( in_array('mcrypt', get_loaded_extensions()) )
{
$string = base64_encode( mcrypt_encrypt( MCRYPT_RIJNDAEL_256, md5($key), $string, MCRYPT_MODE_CBC, md5($key) ) );
return $string;
}
}
return('---');
}
// return string
public static function decrypt($string, $key)
{
if(function_exists('get_loaded_extensions'))
{
if( in_array('mcrypt', get_loaded_extensions()) )
{
$string = rtrim( mcrypt_decrypt( MCRYPT_RIJNDAEL_256, md5($key), base64_decode($string), MCRYPT_MODE_CBC, md5($key) ), "\0" );
return $string;
}
}
return('---');
}
2015-08-03 02:49:12 +02:00
public static function getHash($string, $salt = '$#!')
2015-03-08 18:02:59 +01:00
{
$sha1 = sha1($string.$salt);
return($sha1);
}
}