當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。