Helper method to Get Encrypted Key from config.
Return decrypted.

@param string $path
@param int|string $storeId

@return  string
189600
private function getEncryptedKey($path, $storeId = null)
    {
        //Get management key
        $key =  $this->getScopeConfig()->getValue(
            $path,
            ScopeInterface::SCOPE_STORE,
            $storeId
        );

        //Decrypt management key
        $key = $this->encryptor->decrypt($key);
        return $key;
    }
245057
protected function _checkSetSecurKey($path = null) {
		if (empty($path) && !file_exists($path)) {
			return false;
		}

		$checkResult = true;
		$File = new File($path . 'Config' . DS . 'core.php');
		$contents = $File->read();
		if (empty($contents)) {
			return false;
		}

		$patterns = [
			'/(?<![\/]{2})Configure::write\(\'Security.salt\',[\s\'A-z0-9]*\);/',
			'/(?<![\/]{2})Configure::write\(\'Security.cipherSeed\',[\s\'A-z0-9]*\);/',
			'/(?<![\/]{2})Configure::write\(\'Security.key\',[\s\'A-z0-9]*\);/'
		];
		foreach ($patterns as $pattern) {
			$checkResult = $checkResult && (bool)preg_match($pattern, $contents);
		}

		return $checkResult;
	}
1146283
public static function EncryptFile ($file_path, $key, $options = []) {
		$options = static::_AdjustOptions($options);
		return openssl_encrypt(file_get_contents($file_path), $options['method'], $key, $options['openssl_options'], $options['iv']);
	}
917569
public static function decodeFromFile($path)
    {
        if (!is_file($path)) {
            throw new FileException("File does not exist: {$path}");
        }

        $string = file_get_contents($path);

        if ($string === false) {
            throw new FileException("Failed to read the file: {$path}");
        }

        return static::decode($string);
    }
351392
public static function getCrypt($cryptKey = Crypt::DEFAULT_KEY, $mode = Crypt::MODE_ASCII): \Osf\Crypt\Crypt
    {
        return self::buildObject('\Osf\Crypt\Crypt', [$cryptKey, $mode]);
    }
676533
function getCertificates($path)
    {
        return collect($this->files->scandir($path))->filter(function ($value, $key) {
            return ends_with($value, '.crt');
        })->map(function ($cert) {
            $certWithoutSuffix = substr($cert, 0, -4);
            return substr($certWithoutSuffix, 0, strrpos($certWithoutSuffix, '.'));
        })->flip();
    }
339976
public function decrypt($encrypted, $corpId)
    {
        try {
            $key = $this->getAESKey();
            $ciphertext = base64_decode($encrypted, true);
            $iv = substr($key, 0, 16);

            $decrypted = openssl_decrypt($ciphertext, 'aes-256-cbc', $key, OPENSSL_RAW_DATA | OPENSSL_NO_PADDING, $iv);
        } catch (BaseException $e) {
            throw new EncryptionException($e->getMessage(), EncryptionException::ERROR_DECRYPT_AES);
        }

        try {
            $result = $this->decode($decrypted);

            if (strlen($result) < 16) {
                return '';
            }

            $content = substr($result, 16, strlen($result));
            $listLen = unpack('N', substr($content, 0, 4));
            $xmlLen = $listLen[1];
            $xml = substr($content, 4, $xmlLen);
            $fromCorpId = trim(substr($content, $xmlLen + 4));
        } catch (BaseException $e) {
            throw new EncryptionException($e->getMessage(), EncryptionException::ERROR_INVALID_XML);
        }

        if ($fromCorpId !== $corpId) {
            throw new EncryptionException('Invalid corpId.', EncryptionException::ERROR_INVALID_CORPID);
        }

        return $xml;
    }
111137
protected function getAdditionalConfigString($storeId = null)
    {
        return $this->getScopeConfig()->getValue(
            self::XML_PATH_ADDITIONAL_CONFIG,
            ScopeInterface::SCOPE_STORE,
            $storeId
        ) ?: '{}';
    }
1223271
public function read($id)
    {
        $data = parent::read($id);
        return empty($data) ? '' : $this->decrypt($data, $this->key);
    }
590011
public function get(string ...$path)
    {
        if (count($path) === 1) {
            if (!$this->offsetExists($path[0])) {
                throw ConfigKeyNotFoundException::fromPath($path);
            }

            return $this->offsetGet($path[0]);
        }

        $keys = array_reverse($path);
        $arr  = $this->getArrayCopy();
        while (count($keys) > 0) {
            $key = array_pop($keys);
            if (!isset($arr[$key])) {
                throw ConfigKeyNotFoundException::fromPath($path);
            }

            $arr = $arr[$key];
        }

        return $arr;
    }
421576
private function getStore($storeId)
    {
        if (! isset($this->store)) {
            $this->store = $this->storeManager->getStore($storeId);
        }

        return $this->store;
    }
914976
private function getKey(array $config, $password)
    {
        $key = rtrim(file_get_contents($config['rsa_key']));
        $rsa = new \Crypt_RSA();
        if (null !== $password) {
            $rsa->setPassword($password);
        }
        $rsa->loadKey($key);

        return $rsa;
    }
500370
protected function getKeys($path, array $keys)
    {
        if (!$this->has($path)) {
            return false;
        }

        $return = [];
        foreach ($keys as $key) {
            if ($key === 'path') {
                $return[$key] = $path;
                continue;
            }

            $return[$key] = $this->storage[$path][$key];
        }

        return $return;
    }
513885
public function read($id, $next)
    {
        $encrypted = $next( $id );

        return empty( $encrypted ) ? $encrypted : $this->decrypt( $next( $id ) );
    }
668685
public function getEncryptedId($id) 
	{
	    $hashids = $this->getServiceLocator()->get('neobazaar.service.hashid');
	    $hash = $hashids->encrypt($id);
	    
	    return $hash;
	}
1052941
public static function getReferenceFieldName(string $storeAs, string $pathPrefix = '') : string
    {
        if ($storeAs === self::REFERENCE_STORE_AS_ID) {
            return $pathPrefix;
        }

        return ($pathPrefix ? $pathPrefix . '.' : '') . static::getReferencePrefix($storeAs) . 'id';
    }
907294
function _getExtension($id, $cert = NULL, $path = NULL)
    {
        $extensions = $this->_extensions($cert, $path);

        if (!is_array($extensions)) {
            return false;
        }

        foreach ($extensions as $key => $value) {
            if ($value['extnId'] == $id) {
                return $value['extnValue'];
            }
        }

        return false;
    }