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


PHP mcrypt_list_modes函数代码示例

本文整理汇总了PHP中mcrypt_list_modes函数的典型用法代码示例。如果您正苦于以下问题:PHP mcrypt_list_modes函数的具体用法?PHP mcrypt_list_modes怎么用?PHP mcrypt_list_modes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了mcrypt_list_modes函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _key

function _key($v, $arg)
{
    echo '  key: ' . $v;
    if (count($arg) > 0) {
        echo "\n\n  Arguments:";
        foreach ($arg as $a) {
            echo "\n\t{$a}";
        }
    }
    if ($v == 'generate') {
        if (!is_dir(CONFIG_KEYS_PATH)) {
            mkdir(CONFIG_KEYS_PATH, 0777);
        }
        $base = ['I', 'u', 'h', '5', 'B', 'A', 'r', 'i', '7', '9', 'z', 'd', 'n', 't', 'F', '2', 'W', 'X', 'f', 'e', 'x', 'v', '_', '8', 'm', 'T', 'N', 'R', 'L', 'c', '6', 'P', 'k', 'Q', 'q', 'j', 'Y', 'M', '4', 'S', 'G', 'o', '0', '$', 'K', 's', 'g', 'H', 'E', 'b', 'a', 'J', 'U', 'Z', 'l', '1', 'O', '3', 'y', 'p', 'V', 'D', 'C', 'w'];
        $extra = ['$', '!', '#', '%', '&', '*', '+', '-', '?', '@', '(', ')', '/', '\\', '[', ']', '_', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
        shuffle($base);
        shuffle($extra);
        file_put_contents(CONFIG_KEYS_PATH . 'can.key', implode($base) . "\n" . implode($extra));
        echo "\n\n  New CAN key generated - success!";
        //Now, OPEN_SSL
        include CLI_PATH . 'open.php';
        return "\n\n  OpenSSL keys & certificates - success!";
    } elseif ($v == 'list') {
        echo "\n\n  Ciphers:";
        foreach (mcrypt_list_algorithms() as $x) {
            echo "\n\t" . $x;
        }
        echo "\n\n  Cipher Modes:";
        foreach (mcrypt_list_modes() as $x) {
            echo "\n\t" . $x;
        }
    } else {
        return "\n\n  ----- ERROR: Command 'key:{$v}' not found!\n" . _help();
    }
}
开发者ID:3razil,项目名称:frame,代码行数:35,代码来源:limp.php

示例2: get_system_requirements

 public static function get_system_requirements()
 {
     return [['name' => 'Memory limit', 'expected_value' => '640M', 'current_value' => function () {
         return ini_get('memory_limit');
     }, 'check' => function ($current_value, $expected_value) {
         return intval($current_value) >= intval($expected_value);
     }], ['name' => 'Max execution time', 'expected_value' => '30', 'current_value' => function () {
         return ini_get('max_execution_time');
     }, 'check' => function ($current_value, $expected_value) {
         return intval($current_value) >= intval($expected_value);
     }], ['name' => 'cUrl enabled', 'expected_value' => 'Yes', 'current_value' => function () {
         return extension_loaded('curl') ? 'Yes' : 'No';
     }, 'check' => function ($current_value, $expected_value) {
         return $current_value == 'Yes';
     }], ['name' => 'mCrypt enabled', 'expected_value' => 'Yes', 'current_value' => function () {
         return extension_loaded('mcrypt') ? 'Yes' : 'No';
     }, 'check' => function ($current_value, $expected_value) {
         return $current_value == 'Yes';
     }], ['name' => 'RIJNDAEL 128 available', 'expected_value' => 'Yes', 'current_value' => function () {
         return extension_loaded('mcrypt') && in_array('rijndael-128', mcrypt_list_algorithms()) ? 'Yes' : 'No';
     }, 'check' => function ($current_value, $expected_value) {
         return $current_value == 'Yes';
     }], ['name' => 'CBC mode available', 'expected_value' => 'Yes', 'current_value' => function () {
         return extension_loaded('mcrypt') && in_array('cbc', mcrypt_list_modes()) ? 'Yes' : 'No';
     }, 'check' => function ($current_value, $expected_value) {
         return $current_value == 'Yes';
     }], ['name' => 'SHA512 available', 'expected_value' => 'Yes', 'current_value' => function () {
         return in_array('sha512', hash_algos()) ? 'Yes' : 'No';
     }, 'check' => function ($current_value, $expected_value) {
         return $current_value == 'Yes';
     }]];
 }
开发者ID:ArloSoftware,项目名称:arlowp-plugin,代码行数:32,代码来源:arlo-system-requirements.php

示例3: encryptmode

function encryptmode($config)
{
    if (@function_exists('mcrypt_list_modes')) {
        $listed = array();
        if (!isset($config['mcrypt_mode'])) {
            $config['mcrypt_mode'] = 'cbc';
            /* MCRYPT_MODE_CBC */
        }
        $modes = @mcrypt_list_modes();
        $found = False;
        while (list($key, $value) = each($modes)) {
            $found = True;
            /* Only show each once - seems this is a problem in some installs */
            if (!in_array($value, $listed)) {
                if ($config['mcrypt_mode'] == $value) {
                    $selected = ' selected';
                } else {
                    $selected = '';
                }
                $descr = strtoupper($value);
                $out .= '<option value="' . $value . '"' . $selected . '>' . $descr . '</option>' . "\n";
                $listed[] = $value;
            }
        }
        if (!$found) {
            /* Something is wrong with their mcrypt install or php.ini */
            $out = '<option value="" selected>' . lang('no modes available') . '</option>' . "\n";
        }
    } else {
        $out = '<option value="cbc" selected>CBC</option>' . "\n";
    }
    return $out;
}
开发者ID:BackupTheBerlios,项目名称:milaninegw-svn,代码行数:33,代码来源:hook_config.inc.php

示例4: setMode

 public function setMode($mode)
 {
     $modes = mcrypt_list_modes("/usr/local/lib/libmcrypt");
     if (in_array($mode, $modes)) {
         $this->mode = $mode;
     }
 }
开发者ID:uhtoff,项目名称:eCRF,代码行数:7,代码来源:Encrypt.php

示例5: listModes

 /**
  * @return array
  */
 public static function listModes()
 {
     if (!self::$listModes) {
         $listModes = mcrypt_list_modes();
         self::$listModes = array_combine($listModes, $listModes);
     }
     return self::$listModes;
 }
开发者ID:lytc,项目名称:sloths,代码行数:11,代码来源:Mcrypt.php

示例6: vidtrial_crypto_mode

function vidtrial_crypto_mode()
{
    $modes = mcrypt_list_modes();
    foreach (array("cfb", "ctr") as $mode) {
        if (in_array($mode, $modes)) {
            return $mode;
        }
    }
    throw new Exception("bad installation");
}
开发者ID:ajenta,项目名称:vidtrial,代码行数:10,代码来源:crypto.php

示例7: setMode

 /**
  * 设置mode
  * @param [type] $mode [description]
  */
 function setMode($mode)
 {
     if (!strlen($mode)) {
         return false;
     }
     if (!in_array($mode, mcrypt_list_modes())) {
         return false;
     }
     $this->mode = $mode;
 }
开发者ID:bubutrip,项目名称:bubutrip,代码行数:14,代码来源:mcrypt.php

示例8: encrypt

 /**
  * Encrypt function
  * @param algo (string) algorithm to use
  * @param data (string) data to encrypt
  * @param mode (sting) mode to use for the encryption
  * @return (array) with encrypted data, key and iv size or null if the
  *         algo or mode does not exist
  */
 public static function encrypt($algo, $data, $mode = "cbc")
 {
     if (!in_array(strtolower($algo), mcrypt_list_algorithms())) {
         return null;
     }
     if (!in_array(strtolower($mode), mcrypt_list_modes())) {
         return null;
     }
     $r = self::_encrypt($algo, $data, $mode);
     return $r;
 }
开发者ID:kranack,项目名称:frmwrk,代码行数:19,代码来源:Security.php

示例9: __construct

 public function __construct(string $cipher = null, string $hash = null, string $mode = null, bool $twoStep = true)
 {
     parent::__construct($cipher, $hash, $mode, $twoStep);
     if (!function_exists("mcrypt_list_algorithms")) {
         throw new Exception("Could not find the MCrypt module");
     } elseif (!in_array($this->mCipher, mcrypt_list_algorithms())) {
         throw new Exception("The cipher '" . $this->mCipher . "' is not supported by this platform installation");
     } elseif (!in_array($this->mMode, mcrypt_list_modes())) {
         throw new Exception("The block mode '" . $this->mMode . "' is not supported by this platform installation");
     }
 }
开发者ID:IMPHP,项目名称:libimphp,代码行数:11,代码来源:Encrypter.php

示例10: action_check

 public function action_check()
 {
     $version = explode('.', phpversion());
     if ($version[0] != "5" or $version[0] == "5" and intval($version[1]) < 3) {
         return $this->_view->send_error_message("PHP 5.3 Required: Found " . implode('.', $version));
     }
     if (!function_exists('mysql_connect')) {
         return $this->_view->send_error_message("Missing MySQL support in PHP.");
     }
     if (!function_exists('imagepng')) {
         return $this->_view->send_error_message("Missing GD support in PHP.");
     }
     if (!function_exists('mcrypt_encrypt') or !in_array('rijndael-128', mcrypt_list_algorithms()) or !in_array('nofb', mcrypt_list_modes())) {
         return $this->_view->send_error_message("Missing MCrypt support or Rjindael 128.");
     }
     $this->request->redirect('/install/database');
 }
开发者ID:rrsc,项目名称:beansbooks,代码行数:17,代码来源:install.php

示例11: __construct

 /**
  * Constructor
  *
  * @param string $secret
  * @param string $cipher
  * @param string $mode
  */
 public function __construct($secret, $cipher = 'rijndael-256', $mode = 'ctr')
 {
     if (!extension_loaded('mcrypt')) {
         throw new \RuntimeException('The mcrypt extension must be loaded.');
     }
     if (!in_array($cipher, mcrypt_list_algorithms(), true)) {
         throw new \InvalidArgumentException(sprintf('The cipher "%s" is not supported.', $cipher));
     }
     if (!in_array($mode, mcrypt_list_modes(), true)) {
         throw new \InvalidArgumentException(sprintf('The mode "%s" is not supported.', $mode));
     }
     $this->cipher = $cipher;
     $this->mode = $mode;
     if (0 === strlen($secret)) {
         throw new \InvalidArgumentException('$secret must not be empty.');
     }
     $key = hash('sha256', $secret, true);
     if (strlen($key) > ($size = mcrypt_get_key_size($this->cipher, $this->mode))) {
         $key = substr($key, 0, $size);
     }
     $this->key = $key;
 }
开发者ID:vidinoti,项目名称:JMSPaymentCoreBundle,代码行数:29,代码来源:MCryptEncryptionService.php

示例12: decrypt

 /**
  * RIJNDAEL 256: two-way encryption/decryption, with a URL-safe base64 wrapper.
  *
  * Falls back on XOR encryption/decryption when mcrypt is not available.
  *
  * @package s2Member\Utilities
  * @since 3.5
  *
  * @param str $base64 A string of data to decrypt. Should still be base64 encoded.
  * @param str $key Optional. Key used originally for encryption. Defaults to the one configured for s2Member. Short of that, defaults to: ``wp_salt()``.
  * @return str Decrypted string.
  */
 public static function decrypt($base64 = FALSE, $key = FALSE)
 {
     $base64 = is_string($base64) ? $base64 : "";
     $e = strlen($base64) ? c_ws_plugin__s2member_utils_strings::base64_url_safe_decode($base64) : "";
     if (function_exists("mcrypt_decrypt") && in_array("rijndael-256", mcrypt_list_algorithms()) && in_array("cbc", mcrypt_list_modes()) && strlen($e) && preg_match("/^~r2\\:([a-zA-Z0-9]+)(?:\\:([a-zA-Z0-9]+))?\\|(.*?)\$/s", $e, $iv_md5_e)) {
         $key = c_ws_plugin__s2member_utils_encryption::key($key);
         $key = substr($key, 0, mcrypt_get_key_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC));
         if (strlen($iv_md5_e[3]) && (!$iv_md5_e[2] || $iv_md5_e[2] === md5($iv_md5_e[3]))) {
             $d = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $iv_md5_e[3], MCRYPT_MODE_CBC, $iv_md5_e[1]);
         }
         if (isset($d) && is_string($d) && strlen($d)) {
             if (strlen($d = preg_replace("/^~r2\\|/", "", $d, 1, $r2)) && $r2) {
                 $d = rtrim($d, "");
             } else {
                 // Else we need to empty this out.
                 $d = "";
             }
         }
         return isset($d) && is_string($d) && strlen($d) ? $string = $d : "";
     } else {
         // Fallback on XOR decryption.
         return c_ws_plugin__s2member_utils_encryption::xdecrypt($base64, $key);
     }
 }
开发者ID:donwea,项目名称:nhap.org,代码行数:36,代码来源:utils-encryption.inc.php

示例13: DB_eSession


//.........这里部分代码省略.........
      * The default is off since encryption takes extra resources/time.
      */
     $this->_ENCRYPT = (bool) isset($_param['encrypt']) ? $_param['encrypt'] : FALSE;
     /**
      * The key used to encrypt/decrypt individual field data or the whole
      * session data. Keep this key a secret (keep off the web directory).
      * Use readable characters and make at least 62 UNIQUE characters long.
      */
     $this->_ENCRYPT_KEY = isset($_param['encrypt_key']) ? $_param['encrypt_key'] : "z1Mc6KRxAfNwZ0dGjY5qBXhtrPgJO7eCaUmHvQT3yW8nDsI2VkEpiS4blFoLu9";
     /**
      * Determine if libmcrypt is installed and if it's one of the
      * latest versions.
      */
     $this->_MCRYPT = extension_loaded('mcrypt');
     $this->_MCRYPT_LATEST = FALSE;
     if ($this->_MCRYPT) {
         if (defined('MCRYPT_TRIPLEDES')) {
             // Only defined in >= 2.4.x
             $this->_MCRYPT_LATEST = TRUE;
         }
         /**
          * The key field used to encrypt/decrypt using the mcrypt library.
          */
         $this->_ENC_KEY_HASHED = md5($this->_ENCRYPT_KEY);
         $this->_ENC_ALGO = isset($_param['encrypt_cipher']) ? $_param['encrypt_cipher'] : MCRYPT_GOST;
         $_algo = mcrypt_list_algorithms();
         if (!in_array($this->_ENC_ALGO, $_algo)) {
             // Could not assign the encryption algorithm...
             $this->_setErrMsg('BAD_ALGO', NULL, $this->_ENC_ALGO);
             $this->_handleErrors();
             $this->_ENC_ALGO = NULL;
         }
         $this->_ENC_MODE = isset($_param['encrypt_mode']) ? $_param['encrypt_mode'] : MCRYPT_MODE_CFB;
         $_modes = mcrypt_list_modes();
         if (!in_array($this->_ENC_MODE, $_modes)) {
             // Could not assign the encryption mode...
             $this->_setErrMsg('BAD_ENC_MODE', NULL, $this->_ENC_MODE);
             $this->_handleErrors();
             $this->_ENC_MODE = NULL;
         } else {
             if ($this->_ENC_MODE != MCRYPT_MODE_ECB && $this->_ENC_MODE != MCRYPT_MODE_CBC && $this->_ENC_MODE != MCRYPT_MODE_CFB && $this->_ENC_MODE != MCRYPT_MODE_OFB) {
                 // Could not assign the encryption mode...Use class supported
                 $this->_setErrMsg('BAD_MODE_SUPP', NULL, $this->_ENC_MODE, 'ECB, CBC, CFB, OFB.');
                 $this->_handleErrors();
                 $this->_ENC_MODE = NULL;
             }
         }
     } else {
         $this->_ENC_KEY_HASHED = NULL;
         $this->_ENC_ALGO = NULL;
         $this->_ENC_MODE = NULL;
     }
     /**
      * As of PHP 4.2.0, there is no need to seed the random number
      * generator, however, we'll do it here for portability. This will be
      * needed for use with the encryption/decryption mcrypt routines and
      * generating of a new session ID.
      */
     mt_srand((double) microtime() * 1000000);
     srand((double) microtime() * 1000000);
     /**
      * See if MD5 hashing keys have been passed, otherwise set defaults.
      */
     $this->_KEY_PREFIX = isset($_param['key_prefix']) ? $_param['key_prefix'] : 'O9R^3mp#i|34';
     $this->_KEY_SUFFIX = isset($_param['key_suffix']) ? $_param['key_suffix'] : '+t97!u0K-2L5';
     /**
开发者ID:jfanctil,项目名称:lamoria,代码行数:67,代码来源:class.DB_eSession.php

示例14: mb_substr

<?php

$lipsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do\neiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim\nveniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo\nconsequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum\ndolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident,\nsunt in culpa qui officia deserunt mollit anim id est laborum.";
// Take a plaintext that's an integer number times 16 bytes long.
// 96-byte plaintext is an integer number of blocks for block sizes 8, 16, 24 and 32.
$plaintext = mb_substr($lipsum, 0, 96, '8bit');
$ikm = '';
$iiv = '';
for ($i = 0; $i <= 255; $i += 1) {
    $ikm .= chr($i);
    $iiv .= chr(($i + 128) % 256);
}
$ciphers = mcrypt_list_algorithms();
sort($ciphers);
$modes = mcrypt_list_modes();
sort($modes);
$mcryptCiphertexts = [];
foreach ($ciphers as $cipher) {
    foreach ($modes as $mode) {
        $status = 'Yes';
        $keySize = '';
        $blockSize = '';
        $module = @mcrypt_module_open($cipher, '', $mode, '');
        if ($module === false || !is_resource($module)) {
            $status = 'No';
            continue;
        } else {
            $keySize = mcrypt_get_key_size($cipher, $mode);
            $blockSize = mcrypt_get_block_size($cipher, $mode);
            $padding = $mode === 'cbc' || $mode === 'ecb' ? str_repeat(chr($blockSize), $blockSize) : '';
            $iv = $mode === 'stream' ? '' : substr($iiv, 0, $blockSize);
开发者ID:h2ero,项目名称:mcrypt2openssl,代码行数:31,代码来源:mcrypt_test.php

示例15: intval

$p_encoding = intval(@$_GET['encoding']);
$p_mode = intval(@$_GET['mode']);
$p_key_settings = intval(@$_GET['key']);
$p_iv_settings = intval(@$_GET['iv']);
if ($p_cipher == 0) {
    $p_cipher = 3;
}
if ($p_encoding == 0) {
    $p_encoding = 2;
}
if ($p_mode == 0) {
    $p_mode = 1;
}
$cipherList = mcrypt_list_algorithms();
$cipher = $cipherList[$p_cipher - 1];
$modeList = mcrypt_list_modes();
$mode = $modeList[$p_mode - 1];
$key_iv_list = getKeySettings();
$keysize = intval(mcrypt_get_key_size($cipher, $mode));
$blocksize = intval(mcrypt_get_block_size($cipher, $mode));
$key = genKey($keysize);
$iv = genIV($blocksize);
$encoding_list = list_encoding();
function list_encoding()
{
    $encodings = array("base64", "lower hex", "upper hex", "websafe base64");
    return $encodings;
}
function encode($text, $mode = 2)
{
    switch ($mode) {
开发者ID:thisiseast,项目名称:MCIR,代码行数:31,代码来源:init.php


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