403Webshell
Server IP : 104.26.4.103  /  Your IP : 216.73.216.4
Web Server : nginx/1.27.1
System : Linux in-5 5.15.0-143-generic #153-Ubuntu SMP Fri Jun 13 19:10:45 UTC 2025 x86_64
User : arabianexpress ( 1872)
PHP Version : 8.0.30
Disable Function : exec,passthru,shell_exec,system,proc_open,popen,parse_ini_file,show_source
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /storage/v9321/rimskannur/public_html/wp-content/plugins/site-reviews/plugin/Modules/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /storage/v9321/rimskannur/public_html/wp-content/plugins/site-reviews/plugin/Modules/Encryption.php
<?php

namespace GeminiLabs\SiteReviews\Modules;

class Encryption
{
    public function decode(string $string): string
    {
        return base64_decode(str_replace(['-', '_'], ['+', '/'], $string));
    }

    /**
     * @return string|false
     */
    public function decrypt(string $message)
    {
        try {
            $ciphertext = $this->decode($message);
            return sodium_crypto_secretbox_open($ciphertext, $this->nonce(), $this->key());
        } catch (\Exception $e) {
            glsr_log()->error($e->getMessage());
            return false;
        }
    }

    public function decryptRequest(string $message): array
    {
        if ($message = $this->decrypt($message)) {
            $data = explode('|', $message);
            $data = array_map('sanitize_text_field', $data);
            $action = array_shift($data);
            return compact('action', 'data');
        }
        return [];
    }

    public function encode(string $string): string
    {
        return str_replace(['+', '/', '='], ['-', '_', ''], base64_encode($string));
    }

    /**
     * @return string|false
     */
    public function encrypt(string $message)
    {
        try {
            $ciphertext = sodium_crypto_secretbox($message, $this->nonce(), $this->key());
            return $this->encode($ciphertext);
        } catch (\Exception $e) {
            glsr_log()->error($e->getMessage());
            return false;
        }
    }

    public function encryptRequest(string $action, array $data): string
    {
        $values = array_values(array_map('sanitize_text_field', $data));
        $message = implode('|', $values);
        $message = sprintf('%s|%s', $action, $message);
        return (string) $this->encrypt($message);
    }

    protected function key(): string
    {
        if (!defined('NONCE_KEY')) {
            return '';
        }
        $key = substr(\NONCE_KEY, 0, \SODIUM_CRYPTO_SECRETBOX_KEYBYTES);
        return str_pad($key, \SODIUM_CRYPTO_SECRETBOX_KEYBYTES, '#');
    }

    protected function nonce(): string
    {
        if (!defined('NONCE_SALT')) {
            return '';
        }
        $nonce = substr(\NONCE_SALT, 0, \SODIUM_CRYPTO_SECRETBOX_NONCEBYTES);
        return str_pad($nonce, \SODIUM_CRYPTO_SECRETBOX_NONCEBYTES, '#');
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit