aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/crypto/driver/helper.php
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2013-07-19 20:49:24 +0200
committerMarc Alexander <admin@m-a-styles.de>2013-09-14 13:55:28 +0200
commit9b24fda5cd1f6e85c536dc2bc3e5f1bbdef5b7c2 (patch)
tree9aa7c642dd6cd1638ac1d864600c5285d8c8e23e /phpBB/includes/crypto/driver/helper.php
parent2e453eb2cb682031d7e521d23c3904c8dfeef70c (diff)
downloadforums-9b24fda5cd1f6e85c536dc2bc3e5f1bbdef5b7c2.tar
forums-9b24fda5cd1f6e85c536dc2bc3e5f1bbdef5b7c2.tar.gz
forums-9b24fda5cd1f6e85c536dc2bc3e5f1bbdef5b7c2.tar.bz2
forums-9b24fda5cd1f6e85c536dc2bc3e5f1bbdef5b7c2.tar.xz
forums-9b24fda5cd1f6e85c536dc2bc3e5f1bbdef5b7c2.zip
[feature/passwords] Move files after namespacing changes
PHPBB3-11610
Diffstat (limited to 'phpBB/includes/crypto/driver/helper.php')
-rw-r--r--phpBB/includes/crypto/driver/helper.php143
1 files changed, 0 insertions, 143 deletions
diff --git a/phpBB/includes/crypto/driver/helper.php b/phpBB/includes/crypto/driver/helper.php
deleted file mode 100644
index 308ee7dce2..0000000000
--- a/phpBB/includes/crypto/driver/helper.php
+++ /dev/null
@@ -1,143 +0,0 @@
-<?php
-/**
-*
-* @package phpBB3
-* @copyright (c) 2013 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
-*
-*/
-
-/**
-* @ignore
-*/
-if (!defined('IN_PHPBB'))
-{
- exit;
-}
-
-/**
-* @package crypto
-*/
-class phpbb_crypto_driver_helper
-{
- /** @var phpbb_config */
- protected $driver;
-
- /**
- * base64 alphabet
- * @var string
- */
- public $itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
-
- /**
- * Constructor of crypto driver helper object
- */
- public function __construct($driver)
- {
- $this->driver = $driver;
- }
-
- /**
- * Base64 encode hash
- *
- * @param string $input Input string
- * @param int $count Input string length
- *
- * @return string base64 encoded string
- */
- public function hash_encode64($input, $count)
- {
- $output = '';
- $i = 0;
-
- do
- {
- $value = ord($input[$i++]);
- $output .= $this->itoa64[$value & 0x3f];
-
- if ($i < $count)
- {
- $value |= ord($input[$i]) << 8;
- }
-
- $output .= $this->itoa64[($value >> 6) & 0x3f];
-
- if ($i++ >= $count)
- {
- break;
- }
-
- if ($i < $count)
- {
- $value |= ord($input[$i]) << 16;
- }
-
- $output .= $this->itoa64[($value >> 12) & 0x3f];
-
- if ($i++ >= $count)
- {
- break;
- }
-
- $output .= $this->itoa64[($value >> 18) & 0x3f];
- }
- while ($i < $count);
-
- return $output;
- }
-
- /**
- * Return unique id
- * @param string $extra additional entropy
- *
- * @return string Unique id
- */
- public function unique_id($extra = 'c')
- {
- static $dss_seeded = false;
- global $config;
-
- $val = $config['rand_seed'] . microtime();
- $val = md5($val);
- $config['rand_seed'] = md5($config['rand_seed'] . $val . $extra);
-
- if ($dss_seeded !== true && ($config['rand_seed_last_update'] < time() - rand(1,10)))
- {
- set_config('rand_seed_last_update', time(), true);
- set_config('rand_seed', $config['rand_seed'], true);
- $dss_seeded = true;
- }
-
- return substr($val, 4, 16);
- }
-
- /**
- * Get random salt with specified length
- *
- * @param int $length Salt length
- */
- public function get_random_salt($length)
- {
- $random = '';
-
- if (($fh = @fopen('/dev/urandom', 'rb')))
- {
- $random = fread($fh, $length);
- fclose($fh);
- }
-
- if (strlen($random) < $length)
- {
- $random = '';
- $random_state = $this->unique_id();
-
- for ($i = 0; $i < $length; $i += 16)
- {
- $random_state = md5($this->unique_id() . $random_state);
- $random .= pack('H*', md5($random_state));
- }
- $random = substr($random, 0, $length);
- }
- return $random;
- }
-}