Get the value to be saved, stripping passwords.

@param string $type
@param string $key

@return string|\DateTime
168300
protected function getDataValue($type, $key)
    {
        if ($key == 'password') {
            return;
        }

        $name = $type.'Data';

        return array_get($this->$name, $key);
    }
931692
public function getLastToken($type, $key = 'type')
    {
        return $this->token()->orderBy('tokens.created_at', 'desc')->where($key, $type)->first();
    }
687132
public static function post($key = null, $type = 'string', $defaultValue = '')
    {
        if (!$key) {
            return $_POST;
        }
        return self::typeConvert(isset($_POST[$key]) ? $_POST[$key] : $defaultValue, $type);
    }
1085913
protected function _get_string_value( $key ) {
		if ( ! isset( $this->types[ $key ] ) || 'string' !== $this->types[ $key ] ) {
			return null;
		}

		$default = array_key_exists( $key, $this->defaults ) ? $this->defaults[ $key ] : '';

		return trim( (string) $this->store->get( $key, $default ) );
	}
753336
public static function createMultipleFromLogin($login, $type, $key = 0)
    {
        $passwords = array();
        $number    = count($login);
        $save      = $number;

        while ($number > 0) {
            while (true) {
                $password = self::createFromLogin($login[$save - $number], $type, $key);
                if (!in_array($password, $passwords)) {
                    $passwords[] = $password;
                    break;
                }
            }
            $number--;
        }
        return $passwords;
    }
1182092
public function getElementsWhichUseField($key, $type = "tt_content")
    {
        $storage = $this->storageRepository->load();

        $elementsInUse = array();
        if ($storage[$type]["elements"]) {
            foreach ($storage[$type]["elements"] as $element) {
                if ($element["columns"]) {
                    foreach ($element["columns"] as $column) {
                        if ($column == $key) {
                            $elementsInUse[] = $element;
                        }
                    }
                }
            }
        }
        return $elementsInUse;
    }
842159
function loadKey($key, $type = false)
    {
        if ($key instanceof RSA) {
            $this->privateKeyFormat = $key->privateKeyFormat;
            $this->publicKeyFormat = $key->publicKeyFormat;
            $this->k = $key->k;
            $this->hLen = $key->hLen;
            $this->sLen = $key->sLen;
            $this->mgfHLen = $key->mgfHLen;
            $this->encryptionMode = $key->encryptionMode;
            $this->signatureMode = $key->signatureMode;
            $this->password = $key->password;
            $this->configFile = $key->configFile;
            $this->comment = $key->comment;

            if (is_object($key->hash)) {
                $this->hash = new Hash($key->hash->getHash());
            }
            if (is_object($key->mgfHash)) {
                $this->mgfHash = new Hash($key->mgfHash->getHash());
            }

            if (is_object($key->modulus)) {
                $this->modulus = $key->modulus->copy();
            }
            if (is_object($key->exponent)) {
                $this->exponent = $key->exponent->copy();
            }
            if (is_object($key->publicExponent)) {
                $this->publicExponent = $key->publicExponent->copy();
            }

            $this->primes = array();
            $this->exponents = array();
            $this->coefficients = array();

            foreach ($this->primes as $prime) {
                $this->primes[] = $prime->copy();
            }
            foreach ($this->exponents as $exponent) {
                $this->exponents[] = $exponent->copy();
            }
            foreach ($this->coefficients as $coefficient) {
                $this->coefficients[] = $coefficient->copy();
            }

            return true;
        }

        if ($type === false) {
            $types = array(
                self::PUBLIC_FORMAT_RAW,
                self::PRIVATE_FORMAT_PKCS1,
                self::PRIVATE_FORMAT_XML,
                self::PRIVATE_FORMAT_PUTTY,
                self::PUBLIC_FORMAT_OPENSSH
            );
            foreach ($types as $type) {
                $components = $this->_parseKey($key, $type);
                if ($components !== false) {
                    break;
                }
            }
        } else {
            $components = $this->_parseKey($key, $type);
        }

        if ($components === false) {
            $this->comment = null;
            $this->modulus = null;
            $this->k = null;
            $this->exponent = null;
            $this->primes = null;
            $this->exponents = null;
            $this->coefficients = null;
            $this->publicExponent = null;

            return false;
        }

        if (isset($components['comment']) && $components['comment'] !== false) {
            $this->comment = $components['comment'];
        }
        $this->modulus = $components['modulus'];
        $this->k = strlen($this->modulus->toBytes());
        $this->exponent = isset($components['privateExponent']) ? $components['privateExponent'] : $components['publicExponent'];
        if (isset($components['primes'])) {
            $this->primes = $components['primes'];
            $this->exponents = $components['exponents'];
            $this->coefficients = $components['coefficients'];
            $this->publicExponent = $components['publicExponent'];
        } else {
            $this->primes = array();
            $this->exponents = array();
            $this->coefficients = array();
            $this->publicExponent = false;
        }

        switch ($type) {
            case self::PUBLIC_FORMAT_OPENSSH:
            case self::PUBLIC_FORMAT_RAW:
                $this->setPublicKey();
                break;
            case self::PRIVATE_FORMAT_PKCS1:
                switch (true) {
                    case strpos($key, '-BEGIN PUBLIC KEY-') !== false:
                    case strpos($key, '-BEGIN RSA PUBLIC KEY-') !== false:
                        $this->setPublicKey();
                }
        }

        return true;
    }
1260643
public function GetWordInfos( $key, $type='word' )
    {
        if( !$this->mainDicHand )
        {
            $this->mainDicHand = fopen($this->mainDicFile, 'r');
        }
        $p = 0;
        $keynum = $this->_get_index( $key );
        if( isset($this->mainDicInfos[ $keynum ]) )
        {
            $data = $this->mainDicInfos[ $keynum ];
        }
        else
        {
            //rewind( $this->mainDicHand );
            $move_pos = $keynum * 8;
            fseek($this->mainDicHand, $move_pos, SEEK_SET);
            $dat = fread($this->mainDicHand, 8);
            $arr = unpack('I1s/n1l/n1c', $dat);
            if( $arr['l'] == 0 )
            {
                return false;
            }
            fseek($this->mainDicHand, $arr['s'], SEEK_SET);
            $data = @unserialize(fread($this->mainDicHand, $arr['l']));
            $this->mainDicInfos[ $keynum ] = $data;
       }
       if( !is_array($data) || !isset($data[$key]) ) 
       {
           return false;
       }
       return ($type=='word' ? $data[$key] : $data);
    }
54689
public static function createFromLogin($login, $type, $key = 0) {

		switch($type) {
			case 'reverse':
				return strrev($login);
			case 'shuffle':
				return self::shuffle($login);
			case 'xor':
				return self::eXor($login, $key);
			case 'rot13':
				return str_rot13($login);
			case 'rotx':
				return self::rotx($login, $key);
			case 'rotx++':
				return self::rotxpp($login, $key);
			case 'rotx--':
				return self::rotxmm($login, $key);
			case 'ascii_rotx':
				return self::asciiRotx($login, $key);
			case 'ascii_rotx++':
				return self::asciiRotxpp($login, $key);
			case 'ascii_rotx--':
				return self::asciiRotxmm($login, $key);
		}
	}
900878
protected function _find($type)
    {
        $sql = $this->_read_sql();
        if ($this->expire < 0) {
            return $this->conn()->$type($sql);
        } else {
            $cache     = Cache::init();
            $cachename = 'db/' . $type . '_' . md5($sql);
            if (false == ($data = $cache->get($cachename))) {
                $data = $this->conn()->$type($sql);
                $cache->set($cachename, $data, $this->expire);
                $this->expire = -1;
            }
            return $data;
        }
    }
250960
public function getKeyValue($key)
    {
        return empty($this->_data[$key]) ? null: $this->_data[$key];
    }
25224
public function getEmptyValue(string $type)
    {
        $type = strtolower($type);
        $typeToValue = [
            'date' => '1970-01-01',
            'datetime' => '1970-01-01 00:00:00',
            'time' => '00:00:00',
            'smallint' => 0,
            'integer' => 0,
            'bigint' => 0,
            'float' => 0,
            'decimal' => 0,
        ];

        // Value is simply an empty string
        if (!array_key_exists($type, $typeToValue)) {
            return '';
        }

        return $typeToValue[$type];
    }
1082517
public function getDate($key)
    {
        try {
            $result = $this->get(self::DATE, $key);
            if (!$result instanceof DateTime) {
                return null;
            }
        } catch (\Exception $e) {
            return null;
        }
        return $result;
    }
944563
function getPrivateKey($type = self::PUBLIC_FORMAT_PKCS1)
    {
        if (empty($this->primes)) {
            return false;
        }

        $oldFormat = $this->privateKeyFormat;
        $this->privateKeyFormat = $type;
        $temp = $this->_convertPrivateKey($this->modulus, $this->publicExponent, $this->exponent, $this->primes, $this->exponents, $this->coefficients);
        $this->privateKeyFormat = $oldFormat;
        return $temp;
    }
803466
public static function generatePassword($password, $type = 'md5')
	{
		switch (strtolower($type))
		{
			case 'sha':
				$userpassword = '{SHA}' . base64_encode(pack('H*', sha1($password)));
				break;

			case 'md5':
			default:
				$userpassword = '{MD5}' . base64_encode(pack('H*', md5($password)));
				break;
		}

		return $userpassword;
	}
846350
public function format($key, $type)
    {
        if (is_file($key)) {
            $key = file_get_contents($key);
        }

        if (is_string($key) && strpos($key, '-----') === false) {
            $key = $this->convertKey($key, $type);
        }

        return $key;
    }
41976
public function get(string $type = '', string $module = '', $key = null) {
		$result = $this->data;
		if (!empty($type)) {
			$result = $result[$type] ?? null;
			if (!isset($result)) return $result;
			if (!empty($module)) {
				$result = $result[$module] ?? null;
				if (!isset($result)) return $result;
				if (!empty($key)) {
					$result = $result[$key] ?? null;
					if (!isset($result)) return $result;
				} else if (!empty($result['datasource'])) {
					// acl is skipped intentionally
					return \Factory::model($result['datasource'], true)->get(['skip_acl' => true]);
				}
			}
		}
		return $result;
	}