<?php /** * Helper * * @package surerank * @since 1.0.0 */ namespace SureRank\Inc\GoogleSearchConsole; if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } /** * Helper * This class will handle all helper functions. * * @since 1.0.0 */ class Utils { /** * Encrypt data using base64. * * @param string $input The input string which needs to be encrypted. * @since 1.0.0 * @return string The encrypted string. */ public static function encrypt( $input ) { // If the input is empty or not a string, then abandon ship. if ( empty( $input ) || ! is_string( $input ) ) { return ''; } // Encrypt the input and return it. $base_64 = base64_encode( $input ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode return rtrim( $base_64, '=' ); } /** * Decrypt data using base64. * * @param string $input The input string which needs to be decrypted. * @since 1.0.0 * @return string The decrypted string. */ public static function decrypt( $input ) { // If the input is empty or not a string, then abandon ship. if ( empty( $input ) || ! is_string( $input ) ) { return ''; } // Decrypt the input and return it. $base_64 = $input . str_repeat( '=', strlen( $input ) % 4 ); return base64_decode( $base_64 ); } }