当前位置: 首页>>代码示例>>PHP>>正文


PHP mcrypt_module_self_test函数代码示例

本文整理汇总了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);
 }
开发者ID:havefnubb,项目名称:havefnubb,代码行数:10,代码来源:jCrypt.class.php

示例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);
 }
开发者ID:alienpham,项目名称:helenekling,代码行数:17,代码来源:jCrypt.class.php

示例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
    }
}
开发者ID:emanuelwiesner,项目名称:arcanum,代码行数:37,代码来源:main_funcs.php

示例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;
 }
开发者ID:blazeriaz,项目名称:youguess,代码行数:37,代码来源:Mcrypt.php

示例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;
 }
开发者ID:jccarrizo,项目名称:git-hub-proyect,代码行数:29,代码来源:xcrud.php

示例6: mcrypt_module_self_test

 function mcrypt_module_self_test($algorithm, $lib_dir = '')
 {
     return mcrypt_module_self_test($algorithm, $lib_dir);
 }
开发者ID:phpseclib,项目名称:mcrypt_compat,代码行数:4,代码来源:mcrypt.php

示例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);
 }
开发者ID:EWegrzynowski,项目名称:sysPass,代码行数:9,代码来源:Crypt.class.php

示例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);
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:ext_mcrypt.php

示例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(''));
开发者ID:badlamer,项目名称:hhvm,代码行数:5,代码来源:mcrypt_module_self_test.php

示例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));
 }
开发者ID:robtuley,项目名称:knotwerk,代码行数:8,代码来源:Crypt.php

示例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);
 }
开发者ID:Invision70,项目名称:php-bitpay-client,代码行数:12,代码来源:McryptExtension.php


注:本文中的mcrypt_module_self_test函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。