# woo-mailerlite/3.1.25/includes/common/WooMailerLiteEncryption.php

MailerLite – WooCommerce integration, version 3.1.25. 82 lines.

- Page: https://pluginprobe.com/plugins/woo-mailerlite/3.1.25/code/includes/common/WooMailerLiteEncryption.php
- Raw: https://pluginprobe.com/plugins/woo-mailerlite/3.1.25/raw/includes/common/WooMailerLiteEncryption.php
- Modified: 2026-02-16T09:50:00+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/woo-mailerlite/3.1.25/code/includes/common/WooMailerLiteEncryption.php#L10-L20`.

```php
<?php


class WooMailerLiteEncryption {

    private $key;

    private $salt;

    protected static $instance = null;

    public function __construct() {
        $this->key  = $this->getDefaultKey();
        $this->salt = $this->getDefaultSalt();
    }

    public static function instance()
    {
        if (!empty(static::$instance)) {
            return static::$instance;
        }
        static::$instance = new static();
        return static::$instance;
    }

    public function encrypt( $value ) {
        if ( ! extension_loaded( 'openssl' ) ) {
            return $value;
        }

        $method = 'aes-256-ctr';
        $ivlen  = openssl_cipher_iv_length( $method );
        $iv     = openssl_random_pseudo_bytes( $ivlen );

        $raw_value = openssl_encrypt( $value . $this->salt, $method, $this->key, 0, $iv );
        if ( ! $raw_value ) {
            return false;
        }

        return base64_encode( $iv . $raw_value );
    }

    public function decrypt( $raw_value ) {
        if ( ! extension_loaded( 'openssl' ) ) {
            return $raw_value;
        }

        $raw_value = base64_decode( $raw_value, true );

        $method = 'aes-256-ctr';
        $ivlen  = openssl_cipher_iv_length( $method );
        $iv     = substr( $raw_value, 0, $ivlen );

        $raw_value = substr( $raw_value, $ivlen );

        $value = openssl_decrypt( $raw_value, $method, $this->key, 0, $iv );
        if ( ! $value || substr( $value, - strlen( $this->salt ) ) !== $this->salt ) {
            return false;
        }

        return substr( $value, 0, - strlen( $this->salt ) );
    }

    protected function getDefaultKey()
    {
        if ( defined( 'LOGGED_IN_KEY' ) && '' !== LOGGED_IN_KEY ) {
            return LOGGED_IN_KEY;
        }

        return 'this-is-a-fallback-key-but-not-secure';
    }

    protected function getDefaultSalt()
    {
        if ( defined( 'LOGGED_IN_SALT' ) && '' !== LOGGED_IN_SALT ) {
            return LOGGED_IN_SALT;
        }
        return 'this-is-a-fallback-salt-but-not-secure';
    }

}

```
