本文整理汇总了PHP中mcrypt_module_self_test函数的典型用法代码示例。如果您正苦于以下问题:PHP mcrypt_module_self_test函数的具体用法?PHP mcrypt_module_self_test怎么用?PHP mcrypt_module_self_test使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mcrypt_module_self_test函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: encrypt
public static function encrypt($string, $key = '')
{
$encrypted = null;
if (function_exists("mcrypt_generic") && mcrypt_module_self_test(MCRYPT_WAKE)) {
$encrypted = jCrypt::mcryptEncrypt($string, $key);
} else {
$encrypted = jCrypt::simpleCrypt($string, $key);
}
return base64_encode($encrypted);
}
示例2: encrypt
/**
* Encrypt a string with a specific key
* @param string $string the string to encrypt
* @param string $key the key used to encrypt
* @return string encrypted string
*/
public static function encrypt($string, $key)
{
$encrypted = null;
// Check if mcrypt is installed, and if WAKE algo exists
if (function_exists("mcrypt_generic") && mcrypt_module_self_test(MCRYPT_WAKE)) {
$encrypted = jCrypt::mcryptEncrypt($string, $key);
} else {
$encrypted = jCrypt::simpleCrypt($string, $key);
}
return base64_encode($encrypted);
}
示例3: check_environment
function check_environment()
{
global $config;
//check mcrypt
if (!function_exists('mcrypt_encrypt')) {
throw new arcException('PHPs mcrypt library not available!');
}
//check ciphers
foreach ($config['used_mcrypt_ciphers'] as $cipher => $mode) {
if (!mcrypt_module_self_test($cipher)) {
throw new arcException('Trying to use cipher [' . $cipher . '], but self-test failed!');
}
}
//check paths
if (!is_dir($config['tmppath'])) {
@mkdir($config['tmppath']);
chmod($config['tmppath'], 0700);
}
if (!is_writable($config['tmppath'])) {
throw new arcException("tmppath " . $config['tmppath'] . " is not writable!");
}
if (!is_dir($config['cache_path'])) {
@mkdir($config['cache_path']);
chmod($config['cache_path'], 0700);
}
if (!is_writable($config['cache_path'])) {
throw new arcException("cache_path " . $config['cache_path'] . " is not writable!");
}
$virusscanner = explode(' ', $config['virusscanner']);
if (!is_executable($virusscanner[0]) && $config['enablevirusscan'] === TRUE) {
throw new arcException("Filescanner [" . $config['virusscanner'] . "] not executable");
}
if (!is_dir($config['js_lang_realpath'])) {
@mkdir($config['js_lang_realpath']);
//dont throw any arcException, arcanum may work anyway
}
}
示例4: setEncryption
/**
* Sets new encryption options
*
* @param string|array $options Encryption options
* @return Zend_Filter_File_Encryption
*/
public function setEncryption($options)
{
if (is_string($options)) {
$options = array('key' => $options);
}
if (!is_array($options)) {
#require_once 'Zend/Filter/Exception.php';
throw new Zend_Filter_Exception('Invalid options argument provided to filter');
}
$options = $options + $this->getEncryption();
$algorithms = mcrypt_list_algorithms($options['algorithm_directory']);
if (!in_array($options['algorithm'], $algorithms)) {
#require_once 'Zend/Filter/Exception.php';
throw new Zend_Filter_Exception("The algorithm '{$options['algorithm']}' is not supported");
}
$modes = mcrypt_list_modes($options['mode_directory']);
if (!in_array($options['mode'], $modes)) {
#require_once 'Zend/Filter/Exception.php';
throw new Zend_Filter_Exception("The mode '{$options['mode']}' is not supported");
}
if (!mcrypt_module_self_test($options['algorithm'], $options['algorithm_directory'])) {
#require_once 'Zend/Filter/Exception.php';
throw new Zend_Filter_Exception('The given algorithm can not be used due an internal mcrypt problem');
}
if (!isset($options['vector'])) {
$options['vector'] = null;
}
$this->_encryption = $options;
$this->setVector($options['vector']);
return $this;
}
示例5: decrypt
public function decrypt($text, $iv)
{
if (!Xcrud_config::$alt_encription_key) {
self::error('Please, set <strong>$alt_encription_key</strong> parameter in configuration file');
}
if (!is_callable('mcrypt_module_open')) {
self::error('<strong>mcrypt_module</strong> not found');
}
if (defined('MCRYPT_TWOFISH') && mcrypt_module_self_test(MCRYPT_TWOFISH)) {
$algoritm = MCRYPT_TWOFISH;
} elseif (defined('MCRYPT_RIJNDAEL_256') && mcrypt_module_self_test(MCRYPT_RIJNDAEL_256)) {
$algoritm = MCRYPT_RIJNDAEL_256;
} elseif (defined('MCRYPT_SERPENT') && mcrypt_module_self_test(MCRYPT_SERPENT)) {
$algoritm = MCRYPT_SERPENT;
} elseif (defined('MCRYPT_BLOWFISH') && mcrypt_module_self_test(MCRYPT_BLOWFISH)) {
$algoritm = MCRYPT_BLOWFISH;
} else {
self::error('MCRYPT - Supported algorytm not found');
}
$td = mcrypt_module_open($algoritm, '', MCRYPT_MODE_CFB, '');
$ks = mcrypt_enc_get_key_size($td);
$key = substr(Xcrud_config::$alt_encription_key, 0, $ks);
mcrypt_generic_init($td, $key, base64_decode($iv));
$decrypted = mdecrypt_generic($td, base64_decode($text));
mcrypt_generic_deinit($td);
mcrypt_module_close($td);
$obj = json_decode($decrypted, true);
return $obj;
}
示例6: mcrypt_module_self_test
function mcrypt_module_self_test($algorithm, $lib_dir = '')
{
return mcrypt_module_self_test($algorithm, $lib_dir);
}
示例7: checkCryptModule
/**
* Comprobar si el módulo de encriptación está disponible.
*
* @return bool
*/
public static function checkCryptModule()
{
return mcrypt_module_self_test(MCRYPT_RIJNDAEL_256);
}
示例8: mcrypt_generic_init
mcrypt_generic_init($td, $key, $iv);
$decrypted = mdecrypt_generic($td, $encrypted);
mcrypt_generic_end($td);
mcrypt_module_close($td);
VS($decrypted, "This is very important data");
VERIFY(in_array("blowfish", mcrypt_list_algorithms()));
VERIFY(in_array("cbc", mcrypt_list_modes()));
VS(mcrypt_module_get_algo_block_size("blowfish"), 8);
VS(mcrypt_module_get_algo_key_size("blowfish"), 56);
VS(mcrypt_module_get_supported_key_sizes("blowfish"), array());
VS(mcrypt_module_get_supported_key_sizes("twofish"), array(16, 24, 32));
VS(mcrypt_module_is_block_algorithm_mode("cbc"), true);
VS(mcrypt_module_is_block_algorithm("blowfish"), true);
VS(mcrypt_module_is_block_mode("cbc"), true);
VS(mcrypt_module_self_test(MCRYPT_RIJNDAEL_128), true);
VS(mcrypt_module_self_test("bogus"), false);
$text = "boggles the inivisble monkey will rule the world";
$key = "very secret key";
$iv_size = mcrypt_get_iv_size(MCRYPT_XTEA, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
$enc = mcrypt_encrypt(MCRYPT_XTEA, $key, $text, MCRYPT_MODE_ECB, $iv);
VS(bin2hex($enc), "f522c62002fa16129c8576bcddc6dd0f7ea81991103ba42962d94c8bfff3ee660d53b187d7e989540abf5a729c2f7baf");
$crypttext = mcrypt_decrypt(MCRYPT_XTEA, $key, $enc, MCRYPT_MODE_ECB, $iv);
VS($crypttext, $text);
//////////////////////////////////////////////////////////////////////
$key = "123456789012345678901234567890123456789012345678901234567890";
$CC = "4007000000027";
$encrypted = mcrypt_cbc(MCRYPT_RIJNDAEL_128, substr($key, 0, 32), $CC, MCRYPT_ENCRYPT, substr($key, 32, 16));
$decrypted = mcrypt_cbc(MCRYPT_RIJNDAEL_128, substr($key, 0, 32), $encrypted, MCRYPT_DECRYPT, substr($key, 32, 16));
VERIFY($encrypted !== $decrypted);
VS(trim((string) $decrypted), $CC);
示例9: var_dump
<?php
var_dump(mcrypt_module_self_test(MCRYPT_RIJNDAEL_128));
var_dump(mcrypt_module_self_test(MCRYPT_RC2));
var_dump(mcrypt_module_self_test(''));
示例10: testSelfModuleMcrypt
/**
* Run mcrypt module self-test.
*/
function testSelfModuleMcrypt()
{
$this->assertTrue(mcrypt_module_self_test(MCRYPT_RIJNDAEL_256));
$this->assertTrue(mcrypt_module_self_test(MCRYPT_BLOWFISH));
}
示例11: algoSelfTest
/**
* Performs an internal self-test on the specified mcrypt algorithm and
* returns either boolean true/false depending on if the self-test passed
* or failed.
*
* @param string $cipher_type
* @return boolean
*/
public function algoSelfTest($cipher_type = MCRYPT_TRIPLEDES)
{
return mcrypt_module_self_test($cipher_type);
}